{ config, pkgs, ... }:
let
nix = pkgs.runCommand "nix-2.2" {} "mkdir -p $out";
in
{
services.nix-daemon.enable = true;
services.nix-daemon.enableSocketListener = true;
nix.package = nix;
launchd.labelPrefix = "org.nix-darwin"; # should not have an effect on nix-daemon
test = ''
echo checking nix-daemon service in /Library/LaunchDaemons >&2
grep "org.nixos.nix-daemon" ${config.out}/Library/LaunchDaemons/org.nixos.nix-daemon.plist
grep "/bin/wait4path" ${config.out}/Library/LaunchDaemons/org.nixos.nix-daemon.plist
grep "&&" ${config.out}/Library/LaunchDaemons/org.nixos.nix-daemon.plist
grep "exec ${nix}/bin/nix-daemon" ${config.out}/Library/LaunchDaemons/org.nixos.nix-daemon.plist
(! grep "KeepAlive" ${config.out}/Library/LaunchDaemons/org.nixos.nix-daemon.plist)
grep "Sockets" ${config.out}/Library/LaunchDaemons/org.nixos.nix-daemon.plist
grep "/nix/var/nix/daemon-socket/socket" ${config.out}/Library/LaunchDaemons/org.nixos.nix-daemon.plist
'';
}