1
0
Fork 0
mirror of https://github.com/LnL7/nix-darwin.git synced 2024-12-15 17:51:01 +00:00
nix-darwin/modules/services/nix-daemon.nix
2017-10-08 13:15:13 +02:00

48 lines
1.3 KiB
Nix

{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.nix-daemon;
in
{
options = {
services.nix-daemon.enable = mkOption {
type = types.bool;
default = false;
description = "Whether to activate system at boot time.";
};
services.nix-daemon.tempDir = mkOption {
type = types.nullOr types.path;
default = null;
description = "The TMPDIR to use for nix-daemon.";
};
};
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
'';
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.EnvironmentVariables = config.nix.envVars
// { NIX_SSL_CERT_FILE = "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt"; }
// optionalAttrs (cfg.tempDir != null) { TMPDIR = cfg.tempDir; };
};
};
}