Skip to content

Commit

Permalink
Add zshenv workaround only on darwin systems
Browse files Browse the repository at this point in the history
  • Loading branch information
rake5k committed Jan 3, 2024
1 parent b9d19b5 commit 1fa5e7b
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions home/base/non-nixos/default.nix
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
{ config, lib, pkgs, ... }:

with lib;
{ lib, config, pkgs, ... }:

let

cfg = config.custom.base.non-nixos;
flakeBaseDir = config.home.homeDirectory + "/.nix-config";

inherit (config.lib.custom.sys) isDarwin isLinux;

in

{

options = {
custom.base.non-nixos = {
enable = mkEnableOption "Config for non NixOS systems";
enable = lib.mkEnableOption "Config for non NixOS systems";

installNix = mkEnableOption "Nix installation" // { default = true; };
installNix = lib.mkEnableOption "Nix installation" // { default = true; };
};
};

config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {

home = {
activation.report-changes = config.lib.dag.entryAnywhere ''
${getExe pkgs.nix} store diff-closures $oldGenPath $newGenPath || true
${lib.getExe pkgs.nix} store diff-closures $oldGenPath $newGenPath || true
'';

packages = with pkgs; [
Expand All @@ -32,12 +32,12 @@ in

shellAliases = {
hm-switch = "home-manager switch -b hm-bak --impure --flake '${flakeBaseDir}'";
hm-diff = "home-manager generations | head -n 2 | cut -d' ' -f 7 | tac | xargs ${getExe pkgs.nix} store diff-closures";
hm-diff = "home-manager generations | head -n 2 | cut -d' ' -f 7 | tac | xargs ${lib.getExe pkgs.nix} store diff-closures";
};
};

nix = {
package = mkForce pkgs.nix;
package = lib.mkForce pkgs.nix;
settings = {
experimental-features = [
"nix-command"
Expand All @@ -46,17 +46,18 @@ in
};
};

programs.zsh.envExtra = mkAfter ''
programs.zsh.envExtra = lib.mkAfter ''
hash -f
# FIXME: Necessary for darwin
# Nix
if [ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]; then
. '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh'
fi
# End Nix
${lib.optionalString isDarwin ''
# Nix
if [ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]; then
. '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh'
fi
# End Nix
''}
'';

targets.genericLinux.enable = config.lib.custom.sys.isLinux;
targets.genericLinux.enable = isLinux;
};
}

0 comments on commit 1fa5e7b

Please sign in to comment.