mirror of
https://github.com/LnL7/nix-darwin.git
synced 2024-12-14 11:57:34 +00:00
Add .nix-defexpr to NIX_PATH the way the NixOS module does
This commit is contained in:
parent
08edc0e19a
commit
ffc8ec5c9a
3 changed files with 21 additions and 15 deletions
|
@ -378,7 +378,6 @@ in
|
||||||
# Include default path <darwin-config>.
|
# Include default path <darwin-config>.
|
||||||
{ darwin-config = "${config.environment.darwinConfig}"; }
|
{ darwin-config = "${config.environment.darwinConfig}"; }
|
||||||
"/nix/var/nix/profiles/per-user/root/channels"
|
"/nix/var/nix/profiles/per-user/root/channels"
|
||||||
"$HOME/.nix-defexpr/channels"
|
|
||||||
];
|
];
|
||||||
description = ''
|
description = ''
|
||||||
The default Nix expression search path, used by the Nix
|
The default Nix expression search path, used by the Nix
|
||||||
|
@ -734,21 +733,26 @@ in
|
||||||
(mkIf (config.system.stateVersion > 3) (mkOrder 1200
|
(mkIf (config.system.stateVersion > 3) (mkOrder 1200
|
||||||
[ { darwin-config = "${config.environment.darwinConfig}"; }
|
[ { darwin-config = "${config.environment.darwinConfig}"; }
|
||||||
"/nix/var/nix/profiles/per-user/root/channels"
|
"/nix/var/nix/profiles/per-user/root/channels"
|
||||||
"$HOME/.nix-defexpr/channels"
|
|
||||||
]))
|
]))
|
||||||
];
|
];
|
||||||
|
|
||||||
# Set up the environment variables for running Nix.
|
# Set up the environment variables for running Nix.
|
||||||
environment.variables = cfg.envVars // { NIX_PATH = cfg.nixPath; };
|
environment.variables = cfg.envVars // { NIX_PATH = cfg.nixPath; };
|
||||||
|
|
||||||
# Unreladed to use in NixOS module
|
environment.extraInit =
|
||||||
environment.extraInit = ''
|
''
|
||||||
# Set up secure multi-user builds: non-root users build through the
|
if [ -e "$HOME/.nix-defexpr/channels" ]; then
|
||||||
# Nix daemon.
|
export NIX_PATH="$HOME/.nix-defexpr/channels''${NIX_PATH:+:$NIX_PATH}"
|
||||||
if [ ! -w /nix/var/nix/db ]; then
|
fi
|
||||||
export NIX_REMOTE=daemon
|
'' +
|
||||||
fi
|
# Not in NixOS module
|
||||||
'';
|
''
|
||||||
|
# Set up secure multi-user builds: non-root users build through the
|
||||||
|
# Nix daemon.
|
||||||
|
if [ ! -w /nix/var/nix/db ]; then
|
||||||
|
export NIX_REMOTE=daemon
|
||||||
|
fi
|
||||||
|
'';
|
||||||
|
|
||||||
nix.nrBuildUsers = mkDefault (max 32 (if cfg.settings.max-jobs == "auto" then 0 else cfg.settings.max-jobs));
|
nix.nrBuildUsers = mkDefault (max 32 (if cfg.settings.max-jobs == "auto" then 0 else cfg.settings.max-jobs));
|
||||||
|
|
||||||
|
|
|
@ -125,7 +125,9 @@ let
|
||||||
'';
|
'';
|
||||||
|
|
||||||
nixPath = ''
|
nixPath = ''
|
||||||
darwinConfig=$(NIX_PATH=${concatStringsSep ":" config.nix.nixPath} nix-instantiate --find-file darwin-config) || true
|
nixPath=${concatStringsSep ":" config.nix.nixPath}:$HOME/.nix-defexpr/channels
|
||||||
|
|
||||||
|
darwinConfig=$(NIX_PATH=$nixPath nix-instantiate --find-file darwin-config) || true
|
||||||
if ! test -e "$darwinConfig"; then
|
if ! test -e "$darwinConfig"; then
|
||||||
echo "[1;31merror: Changed <darwin-config> but target does not exist, aborting activation[0m" >&2
|
echo "[1;31merror: Changed <darwin-config> but target does not exist, aborting activation[0m" >&2
|
||||||
echo "Create ''${darwinConfig:-~/.nixpkgs/darwin-configuration.nix} or set environment.darwinConfig:" >&2
|
echo "Create ''${darwinConfig:-~/.nixpkgs/darwin-configuration.nix} or set environment.darwinConfig:" >&2
|
||||||
|
@ -139,7 +141,7 @@ let
|
||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
darwinPath=$(NIX_PATH=${concatStringsSep ":" config.nix.nixPath} nix-instantiate --find-file darwin) || true
|
darwinPath=$(NIX_PATH=$nixPath nix-instantiate --find-file darwin) || true
|
||||||
if ! test -e "$darwinPath"; then
|
if ! test -e "$darwinPath"; then
|
||||||
echo "[1;31merror: Changed <darwin> but target does not exist, aborting activation[0m" >&2
|
echo "[1;31merror: Changed <darwin> but target does not exist, aborting activation[0m" >&2
|
||||||
echo "Add the darwin repo as a channel or set nix.nixPath:" >&2
|
echo "Add the darwin repo as a channel or set nix.nixPath:" >&2
|
||||||
|
@ -153,7 +155,7 @@ let
|
||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
nixpkgsPath=$(NIX_PATH=${concatStringsSep ":" config.nix.nixPath} nix-instantiate --find-file nixpkgs) || true
|
nixpkgsPath=$(NIX_PATH=$nixPath nix-instantiate --find-file nixpkgs) || true
|
||||||
if ! test -e "$nixpkgsPath"; then
|
if ! test -e "$nixpkgsPath"; then
|
||||||
echo "[1;31merror: Changed <nixpkgs> but target does not exist, aborting activation[0m" >&2
|
echo "[1;31merror: Changed <nixpkgs> but target does not exist, aborting activation[0m" >&2
|
||||||
echo "Add a nixpkgs channel or set nix.nixPath:" >&2
|
echo "Add a nixpkgs channel or set nix.nixPath:" >&2
|
||||||
|
|
|
@ -145,13 +145,13 @@ stdenv.mkDerivation {
|
||||||
env -i USER=john HOME=/Users/john bash -li -c 'echo $PATH'
|
env -i USER=john HOME=/Users/john bash -li -c 'echo $PATH'
|
||||||
env -i USER=john HOME=/Users/john bash -li -c 'echo $PATH' | grep /Users/john/.nix-profile/bin:/run/current-system/sw/bin:/nix/var/nix/profiles/default/bin:/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin
|
env -i USER=john HOME=/Users/john bash -li -c 'echo $PATH' | grep /Users/john/.nix-profile/bin:/run/current-system/sw/bin:/nix/var/nix/profiles/default/bin:/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin
|
||||||
env -i USER=john HOME=/Users/john bash -li -c 'echo $NIX_PATH'
|
env -i USER=john HOME=/Users/john bash -li -c 'echo $NIX_PATH'
|
||||||
env -i USER=john HOME=/Users/john bash -li -c 'echo $NIX_PATH' | grep darwin-config=/Users/john/.nixpkgs/darwin-configuration.nix:/nix/var/nix/profiles/per-user/root/channels:/Users/john/.nix-defexpr/channels
|
env -i USER=john HOME=/Users/john bash -li -c 'echo $NIX_PATH' | grep darwin-config=/Users/john/.nixpkgs/darwin-configuration.nix:/nix/var/nix/profiles/per-user/root/channels
|
||||||
|
|
||||||
echo >&2 "checking zsh environment"
|
echo >&2 "checking zsh environment"
|
||||||
env -i USER=john HOME=/Users/john zsh -l -c 'echo $PATH'
|
env -i USER=john HOME=/Users/john zsh -l -c 'echo $PATH'
|
||||||
env -i USER=john HOME=/Users/john zsh -l -c 'echo $PATH' | grep /Users/john/.nix-profile/bin:/run/current-system/sw/bin:/nix/var/nix/profiles/default/bin:/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin
|
env -i USER=john HOME=/Users/john zsh -l -c 'echo $PATH' | grep /Users/john/.nix-profile/bin:/run/current-system/sw/bin:/nix/var/nix/profiles/default/bin:/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin
|
||||||
env -i USER=john HOME=/Users/john zsh -l -c 'echo $NIX_PATH' | grep darwin-config=/Users/john/.nixpkgs/darwin-configuration.nix:/nix/var/nix/profiles/per-user/root/channels:/Users/john/.nix-defexpr/channels
|
|
||||||
env -i USER=john HOME=/Users/john zsh -l -c 'echo $NIX_PATH'
|
env -i USER=john HOME=/Users/john zsh -l -c 'echo $NIX_PATH'
|
||||||
|
env -i USER=john HOME=/Users/john zsh -l -c 'echo $NIX_PATH' | grep darwin-config=/Users/john/.nixpkgs/darwin-configuration.nix:/nix/var/nix/profiles/per-user/root/channels
|
||||||
|
|
||||||
echo >&2 ok
|
echo >&2 ok
|
||||||
exit
|
exit
|
||||||
|
|
Loading…
Reference in a new issue