1
0
Fork 0
mirror of https://github.com/LnL7/nix-darwin.git synced 2025-03-28 02:37:09 +00:00

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;
This commit is contained in:
Daiderd Jordan 2018-06-21 15:20:49 +02:00
parent a2a7e8173f
commit 27a5758728
No known key found for this signature in database
GPG key ID: D02435D05B810C96

View file

@ -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";