1
0
Fork 0
mirror of https://github.com/LnL7/nix-darwin.git synced 2025-03-06 16:57:08 +00:00
nix-darwin/pkgs/nix-tools/default.nix
Emily b5b7888793 nix-tools: set $NIX_PATH
This will be important once most users are running `sudo
darwin-rebuild` and therefore not getting their environment’s
`$NIX_PATH` passed through.
2025-01-20 05:29:44 +00:00

69 lines
1.7 KiB
Nix
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{ 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 theyre 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 [ coreutils jq git ];
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;
}