summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/nix/default.nix24
-rw-r--r--modules/system/checks.nix8
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 "error: Changed <darwin-config> but target does not exist, aborting activation" >&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 "error: Changed <darwin> but target does not exist, aborting activation" >&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 "error: Changed <nixpkgs> but target does not exist, aborting activation" >&2
echo "Add a nixpkgs channel or set nix.nixPath:" >&2