2023-06-20 22:54:31 +10:00
|
|
|
|
{ lib
|
|
|
|
|
, coreutils
|
|
|
|
|
, jq
|
|
|
|
|
, git
|
|
|
|
|
, substituteAll
|
|
|
|
|
, stdenv
|
|
|
|
|
, profile ? "/nix/var/nix/profiles/system"
|
2025-01-18 20:27:17 +00:00
|
|
|
|
, # 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"
|
|
|
|
|
]
|
2025-01-11 15:44:41 +00:00
|
|
|
|
, # 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"
|
|
|
|
|
]
|
2023-06-20 22:54:31 +10:00
|
|
|
|
}:
|
2023-06-10 00:23:02 +10:00
|
|
|
|
|
|
|
|
|
let
|
2025-01-11 15:44:41 +00:00
|
|
|
|
extraPath = lib.makeBinPath [ coreutils jq git ];
|
2023-06-20 22:54:31 +10:00
|
|
|
|
|
|
|
|
|
writeProgram = name: env: src:
|
|
|
|
|
substituteAll ({
|
|
|
|
|
inherit name src;
|
|
|
|
|
dir = "bin";
|
|
|
|
|
isExecutable = true;
|
2024-11-16 21:53:32 +11:00
|
|
|
|
meta.mainProgram = name;
|
2023-06-20 22:54:31 +10:00
|
|
|
|
} // env);
|
|
|
|
|
|
|
|
|
|
path = "${extraPath}:${systemPath}";
|
|
|
|
|
in
|
|
|
|
|
{
|
|
|
|
|
darwin-option = writeProgram "darwin-option"
|
|
|
|
|
{
|
2025-01-11 15:44:41 +00:00
|
|
|
|
inherit path nixPath;
|
2023-06-20 22:54:31 +10:00
|
|
|
|
inherit (stdenv) shell;
|
|
|
|
|
}
|
|
|
|
|
./darwin-option.sh;
|
|
|
|
|
|
|
|
|
|
darwin-rebuild = writeProgram "darwin-rebuild"
|
|
|
|
|
{
|
2025-01-11 15:44:41 +00:00
|
|
|
|
inherit path nixPath profile;
|
2023-06-20 22:54:31 +10:00
|
|
|
|
inherit (stdenv) shell;
|
2024-01-27 19:33:54 -08:00
|
|
|
|
postInstall = ''
|
|
|
|
|
mkdir -p $out/share/zsh/site-functions
|
|
|
|
|
cp ${./darwin-rebuild.zsh-completions} $out/share/zsh/site-functions/_darwin-rebuild
|
|
|
|
|
'';
|
2023-06-20 22:54:31 +10:00
|
|
|
|
}
|
|
|
|
|
./darwin-rebuild.sh;
|
2023-07-02 01:11:16 +10:00
|
|
|
|
|
|
|
|
|
darwin-version = writeProgram "darwin-version"
|
|
|
|
|
{
|
|
|
|
|
inherit (stdenv) shell;
|
|
|
|
|
path = lib.makeBinPath [ jq ];
|
|
|
|
|
}
|
|
|
|
|
./darwin-version.sh;
|
2023-06-10 00:23:02 +10:00
|
|
|
|
}
|