diff --git a/modules/nix/nix-darwin.nix b/modules/nix/nix-darwin.nix index 4a989d791..a064f49a4 100644 --- a/modules/nix/nix-darwin.nix +++ b/modules/nix/nix-darwin.nix @@ -4,7 +4,7 @@ let nix-tools = pkgs.callPackage ../../pkgs/nix-tools { inherit (config.system) profile; inherit (config.environment) systemPath; - nixPackage = config.nix.package; + nixPath = lib.concatStringsSep ":" config.nix.nixPath; }; darwin-uninstaller = pkgs.callPackage ../../pkgs/darwin-uninstaller { }; diff --git a/pkgs/nix-tools/darwin-option.sh b/pkgs/nix-tools/darwin-option.sh index 8e40e93c0..79ecee91e 100755 --- a/pkgs/nix-tools/darwin-option.sh +++ b/pkgs/nix-tools/darwin-option.sh @@ -1,7 +1,9 @@ #! @shell@ set -e set -o pipefail -export PATH=@path@:$PATH + +export PATH=@path@ +export NIX_PATH=${NIX_PATH:-@nixPath@} evalNix() { nix-instantiate --eval --strict "${extraEvalFlags[@]}" -E "with import {}; $*" 2>/dev/null diff --git a/pkgs/nix-tools/darwin-rebuild.sh b/pkgs/nix-tools/darwin-rebuild.sh index 844c0a8e2..8f207a7a3 100644 --- a/pkgs/nix-tools/darwin-rebuild.sh +++ b/pkgs/nix-tools/darwin-rebuild.sh @@ -1,8 +1,9 @@ #! @shell@ set -e set -o pipefail -export PATH=@path@:$PATH +export PATH=@path@ +export NIX_PATH=${NIX_PATH:-@nixPath@} showSyntax() { echo "darwin-rebuild [--help] {edit | switch | activate | build | check | changelog}" >&2 diff --git a/pkgs/nix-tools/default.nix b/pkgs/nix-tools/default.nix index 4a496bb15..8d6b89b7a 100644 --- a/pkgs/nix-tools/default.nix +++ b/pkgs/nix-tools/default.nix @@ -5,12 +5,31 @@ , substituteAll , stdenv , profile ? "/nix/var/nix/profiles/system" -, nixPackage ? "/nix/var/nix/profiles/default" -, systemPath ? "$HOME/.nix-profile/bin:/etc/profiles/per-user/$USER/bin:/run/current-system/sw/bin:/nix/var/nix/profiles/default/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" +, # This should be kept in sync with the default + # `environment.systemPath`. We err on side of including conditional + # things like the profile directories, since they’re more likely to + # help than hurt, and this default is mostly used for fresh + # installations anyway. + systemPath ? lib.concatStringsSep ":" [ + "$HOME/.nix-profile/bin" + "/etc/profiles/per-user/$USER/bin" + "/run/current-system/sw/bin" + "/nix/var/nix/profiles/default/bin" + "/usr/local/bin" + "/usr/bin" + "/bin" + "/usr/sbin" + "/sbin" +] +, # This should be kept in sync with the default `nix.nixPath`. + nixPath ? lib.concatStringsSep ":" [ + "darwin-config=/etc/nix-darwin/configuration.nix" + "/nix/var/nix/profiles/per-user/root/channels" +] }: let - extraPath = lib.makeBinPath [ nixPackage coreutils jq git ]; + extraPath = lib.makeBinPath [ coreutils jq git ]; writeProgram = name: env: src: substituteAll ({ @@ -25,14 +44,14 @@ in { darwin-option = writeProgram "darwin-option" { - inherit path; + inherit path nixPath; inherit (stdenv) shell; } ./darwin-option.sh; darwin-rebuild = writeProgram "darwin-rebuild" { - inherit path profile; + inherit path nixPath profile; inherit (stdenv) shell; postInstall = '' mkdir -p $out/share/zsh/site-functions