diff options
| author | Daiderd Jordan <daiderd@gmail.com> | 2018-06-21 15:20:49 +0200 |
|---|---|---|
| committer | Daiderd Jordan <daiderd@gmail.com> | 2018-06-21 15:20:49 +0200 |
| commit | 27a5758728d34cc71aa39af0bd8d84ad7ef46db1 (patch) | |
| tree | b93b331e2f2f12151932a74ac232eccc6f630f3d /modules | |
| parent | a2a7e8173fd79e3f19d7f765b7ba0d6ccd250d50 (diff) | |
nix-daemon: add option to make service socket activated
This makes the service start on demand when a client connects to the
daemon socket, instead of keeping it alive.
services.nix-daemon.enableSocketListener = true;
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/services/nix-daemon.nix | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/modules/services/nix-daemon.nix b/modules/services/nix-daemon.nix index c19c159..978ad51 100644 --- a/modules/services/nix-daemon.nix +++ b/modules/services/nix-daemon.nix @@ -14,6 +14,12 @@ in description = "Whether to enable the nix-daemon service."; }; + services.nix-daemon.enableSocketListener = mkOption { + type = types.bool; + default = false; + description = "Whether to make the nix-daemon service socket activated."; + }; + services.nix-daemon.logFile = mkOption { type = types.nullOr types.path; default = null; @@ -39,13 +45,19 @@ in launchd.daemons.nix-daemon = { command = "${config.nix.package}/bin/nix-daemon"; - serviceConfig.KeepAlive = true; serviceConfig.ProcessType = "Interactive"; serviceConfig.LowPriorityIO = config.nix.daemonIONice; serviceConfig.Nice = config.nix.daemonNiceLevel; serviceConfig.SoftResourceLimits.NumberOfFiles = 4096; serviceConfig.StandardErrorPath = cfg.logFile; + serviceConfig.KeepAlive = mkIf (!cfg.enableSocketListener) true; + + serviceConfig.Sockets = mkIf cfg.enableSocketListener + { Listeners.SockType = "stream"; + Listeners.SockPathName = "/nix/var/nix/daemon-socket/socket"; + }; + serviceConfig.EnvironmentVariables = mkMerge [ config.nix.envVars { NIX_SSL_CERT_FILE = mkDefault "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt"; |
