Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nix-daemon: use PathState to wait for nix store #1385

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions modules/services/nix-daemon.nix
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,25 @@ in
};
};

config = mkIf config.nix.enable {
config = let
nixDaemonCmd = lib.getExe' config.nix.package "nix-daemon";
keepAliveArgs = if cfg.enableSocketListener then {
command = nixDaemonCmd;
} else {
serviceConfig.ProgramArguments = [ nixDaemonCmd ];
serviceConfig.KeepAlive.PathState = {
"/nix/store" = true;
};
};
in mkIf config.nix.enable {

launchd.daemons.nix-daemon = {
command = lib.getExe' config.nix.package "nix-daemon";
launchd.daemons.nix-daemon = lib.recursiveUpdate {
serviceConfig.ProcessType = config.nix.daemonProcessType;
serviceConfig.LowPriorityIO = config.nix.daemonIOLowPriority;
serviceConfig.Label = "org.nixos.nix-daemon"; # must match daemon installed by Nix regardless of the launchd label Prefix
serviceConfig.SoftResourceLimits.NumberOfFiles = mkDefault 1048576;
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";
Expand All @@ -68,7 +75,6 @@ in
OBJC_DISABLE_INITIALIZE_FORK_SAFETY = mkDefault "YES";
}
];
};

} keepAliveArgs;
};
}
5 changes: 2 additions & 3 deletions tests/services-nix-daemon.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ in
test = ''
echo checking nix-daemon service in /Library/LaunchDaemons >&2
grep "<string>org.nixos.nix-daemon</string>" ${config.out}/Library/LaunchDaemons/org.nixos.nix-daemon.plist
grep "<string>/bin/wait4path" ${config.out}/Library/LaunchDaemons/org.nixos.nix-daemon.plist
grep "&amp;&amp;" ${config.out}/Library/LaunchDaemons/org.nixos.nix-daemon.plist
grep "exec ${nix}/bin/nix-daemon</string>" ${config.out}/Library/LaunchDaemons/org.nixos.nix-daemon.plist
grep "${nix}/bin/nix-daemon</string>" ${config.out}/Library/LaunchDaemons/org.nixos.nix-daemon.plist
grep "<key>KeepAlive</key>" ${config.out}/Library/LaunchDaemons/org.nixos.nix-daemon.plist
grep "<key>PathState</key>" ${config.out}/Library/LaunchDaemons/org.nixos.nix-daemon.plist
(! grep "<key>Sockets</key>" ${config.out}/Library/LaunchDaemons/org.nixos.nix-daemon.plist)

echo checking NIX_SSL_CERT_FILE in nix-daemon service >&2
Expand Down