diff --git a/modules/nix/nix-darwin.nix b/modules/nix/nix-darwin.nix index 4fed9fd..a064f49 100644 --- a/modules/nix/nix-darwin.nix +++ b/modules/nix/nix-darwin.nix @@ -4,6 +4,7 @@ let nix-tools = pkgs.callPackage ../../pkgs/nix-tools { inherit (config.system) profile; inherit (config.environment) systemPath; + 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 d4cb548..79ecee9 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@ +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 74ec7ec..2e250c5 100644 --- a/pkgs/nix-tools/darwin-rebuild.sh +++ b/pkgs/nix-tools/darwin-rebuild.sh @@ -1,7 +1,9 @@ #! @shell@ set -e set -o pipefail + 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 582309e..8d6b89b 100644 --- a/pkgs/nix-tools/default.nix +++ b/pkgs/nix-tools/default.nix @@ -21,6 +21,11 @@ "/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 @@ -39,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