mirror of
https://github.com/LnL7/nix-darwin.git
synced 2025-03-31 04:04:45 +00:00
(With some tweaks to handle `nix.enable` and order it at a more
sensible position in the `$PATH`.)
The installers actually install Nix into `root`’s profile for some
reason, which means that the path’s prioritization backfires when
the script runs as root and we’re managing the Nix installation. When
running `darwin-rebuild` as a normal user, this wasn’t a problem.
Maybe we should just have a check to make sure there’s no conflicting
Nix in `root`’s profile – it seems pretty bad for `root` to
get the wrong Nix – but it would trigger for almost everyone,
which seems kind of annoying. I guess we could automatically
remove it from `root`’s profile if it matches what’s in
`/nix/var/nix/profiles/default`…
This reverts commit 02232f71c5
.
70 lines
1.7 KiB
Nix
70 lines
1.7 KiB
Nix
{ lib
|
||
, coreutils
|
||
, jq
|
||
, git
|
||
, substituteAll
|
||
, stdenv
|
||
, profile ? "/nix/var/nix/profiles/system"
|
||
, # 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"
|
||
]
|
||
, nixPackage ? null
|
||
, # 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 [ coreutils jq git nixPackage ];
|
||
|
||
writeProgram = name: env: src:
|
||
substituteAll ({
|
||
inherit name src;
|
||
dir = "bin";
|
||
isExecutable = true;
|
||
meta.mainProgram = name;
|
||
} // env);
|
||
|
||
path = "${extraPath}:${systemPath}";
|
||
in
|
||
{
|
||
darwin-option = writeProgram "darwin-option"
|
||
{
|
||
inherit path nixPath;
|
||
inherit (stdenv) shell;
|
||
}
|
||
./darwin-option.sh;
|
||
|
||
darwin-rebuild = writeProgram "darwin-rebuild"
|
||
{
|
||
inherit path nixPath profile;
|
||
inherit (stdenv) shell;
|
||
postInstall = ''
|
||
mkdir -p $out/share/zsh/site-functions
|
||
cp ${./darwin-rebuild.zsh-completions} $out/share/zsh/site-functions/_darwin-rebuild
|
||
'';
|
||
}
|
||
./darwin-rebuild.sh;
|
||
|
||
darwin-version = writeProgram "darwin-version"
|
||
{
|
||
inherit (stdenv) shell;
|
||
path = lib.makeBinPath [ jq ];
|
||
}
|
||
./darwin-version.sh;
|
||
}
|