Skip to content

Commit

Permalink
Merge pull request #1282 from emilazy/push-uqnyoyklywvo
Browse files Browse the repository at this point in the history
nix-tools: drop `nixPackage`, overwrite `$PATH` rather than prepending, set `$NIX_PATH`
  • Loading branch information
emilazy authored Jan 26, 2025
2 parents 65cc1fa + b5b7888 commit 62ba0a2
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 8 deletions.
2 changes: 1 addition & 1 deletion modules/nix/nix-darwin.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 { };
Expand Down
4 changes: 3 additions & 1 deletion pkgs/nix-tools/darwin-option.sh
Original file line number Diff line number Diff line change
@@ -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 <darwin> {}; $*" 2>/dev/null
Expand Down
3 changes: 2 additions & 1 deletion pkgs/nix-tools/darwin-rebuild.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down
29 changes: 24 additions & 5 deletions pkgs/nix-tools/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 ({
Expand All @@ -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
Expand Down

0 comments on commit 62ba0a2

Please sign in to comment.