diff options
| author | Malo Bourgon <mbourgon@gmail.com> | 2022-08-14 14:04:20 -0700 |
|---|---|---|
| committer | Malo Bourgon <mbourgon@gmail.com> | 2022-08-16 17:41:08 -0700 |
| commit | ffc8ec5c9ae6cf7b3bb95866432e30e46e7cc731 (patch) | |
| tree | 3b587dd7970db13ac58519771c545f2597e785ff /modules | |
| parent | 08edc0e19ac33435bd2b5dede373a2bea9f13b49 (diff) | |
Add .nix-defexpr to NIX_PATH the way the NixOS module does
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/nix/default.nix | 24 | ||||
| -rw-r--r-- | modules/system/checks.nix | 8 |
2 files changed, 19 insertions, 13 deletions
diff --git a/modules/nix/default.nix b/modules/nix/default.nix index c816648..6b32caa 100644 --- a/modules/nix/default.nix +++ b/modules/nix/default.nix @@ -378,7 +378,6 @@ in # Include default path <darwin-config>. { darwin-config = "${config.environment.darwinConfig}"; } "/nix/var/nix/profiles/per-user/root/channels" - "$HOME/.nix-defexpr/channels" ]; description = '' The default Nix expression search path, used by the Nix @@ -734,21 +733,26 @@ in (mkIf (config.system.stateVersion > 3) (mkOrder 1200 [ { darwin-config = "${config.environment.darwinConfig}"; } "/nix/var/nix/profiles/per-user/root/channels" - "$HOME/.nix-defexpr/channels" ])) ]; # Set up the environment variables for running Nix. environment.variables = cfg.envVars // { NIX_PATH = cfg.nixPath; }; - # Unreladed to use in NixOS module - environment.extraInit = '' - # 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 - ''; + environment.extraInit = + '' + if [ -e "$HOME/.nix-defexpr/channels" ]; then + export NIX_PATH="$HOME/.nix-defexpr/channels''${NIX_PATH:+:$NIX_PATH}" + 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)); diff --git a/modules/system/checks.nix b/modules/system/checks.nix index 2af25c8..4ce6991 100644 --- a/modules/system/checks.nix +++ b/modules/system/checks.nix @@ -125,7 +125,9 @@ let ''; 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 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 @@ -139,7 +141,7 @@ let exit 2 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 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 @@ -153,7 +155,7 @@ let exit 2 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 echo "[1;31merror: Changed <nixpkgs> but target does not exist, aborting activation[0m" >&2 echo "Add a nixpkgs channel or set nix.nixPath:" >&2 |
