1
0
Fork 0
mirror of https://github.com/LnL7/nix-darwin.git synced 2025-03-13 20:30:02 +00:00

nix: reload daemon when nix.conf changes

This commit is contained in:
Daiderd Jordan 2018-01-03 20:10:24 +01:00
parent 8b10783bda
commit f63f4fe3fb
No known key found for this signature in database
GPG key ID: D02435D05B810C96
3 changed files with 28 additions and 8 deletions

View file

@ -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
'';
};
}

View file

@ -11,7 +11,7 @@ in
services.nix-daemon.enable = mkOption {
type = types.bool;
default = false;
description = "Whether to activate system at boot time.";
description = "Whether to enable the nix-daemon service.";
};
services.nix-daemon.logFile = mkOption {
@ -35,13 +35,7 @@ in
config = mkIf cfg.enable {
environment.extraInit = ''
# 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
'';
nix.useDaemon = true;
launchd.daemons.nix-daemon = {
command = "${config.nix.package}/bin/nix-daemon";

View file

@ -56,6 +56,7 @@ in
${cfg.activationScripts.applications.text}
${cfg.activationScripts.etc.text}
${cfg.activationScripts.launchd.text}
${cfg.activationScripts.nix-daemon.text}
${cfg.activationScripts.time.text}
${cfg.activationScripts.networking.text}