diff options
| author | Daiderd Jordan <daiderd@gmail.com> | 2018-01-03 20:10:24 +0100 |
|---|---|---|
| committer | Daiderd Jordan <daiderd@gmail.com> | 2018-01-03 20:10:24 +0100 |
| commit | f63f4fe3fb7449fcd4526474f5b0e87190ca4a74 (patch) | |
| tree | 39bdc96386c67a3c369c7a1f4cdb086e792c4c3e /modules/nix/default.nix | |
| parent | 8b10783bda1e2169b456218424b3ca61171474ef (diff) | |
nix: reload daemon when nix.conf changes
Diffstat (limited to 'modules/nix/default.nix')
| -rw-r--r-- | modules/nix/default.nix | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/modules/nix/default.nix b/modules/nix/default.nix index c826713..9381a7c 100644 --- a/modules/nix/default.nix +++ b/modules/nix/default.nix @@ -54,6 +54,16 @@ in ''; }; + nix.useDaemon = mkOption { + type = types.bool; + default = false; + description = " + If set, Nix will use the daemon to perform operations. + Use this instead of services.nix-daemon.enable if you don't wan't the + daemon service to be managed for you. + "; + }; + nix.maxJobs = mkOption { type = types.int; default = 1; @@ -346,6 +356,14 @@ in NIX_CURRENT_LOAD = "/run/nix/current-load"; }; + environment.extraInit = mkIf cfg.useDaemon '' + # Set up secure multi-user builds: non-root users build through the + # Nix daemon. + if [ "$USER" != root -o ! -w /nix/var/nix/db ]; then + export NIX_REMOTE=daemon + fi + ''; + # Set up the environment variables for running Nix. environment.variables = cfg.envVars // { NIX_PATH = concatStringsSep ":" cfg.nixPath; @@ -357,5 +375,12 @@ in fi ''; + system.activationScripts.nix-daemon.text = mkIf cfg.useDaemon '' + if ! diff /etc/nix/nix.conf /run/current-system/etc/nix/nix.conf &> /dev/null; then + echo "reloading nix-daemon..." >&2 + pkill -HUP nix-daemon + fi + ''; + }; } |
