diff --git a/modules/services/audio/alsa.nix b/modules/services/audio/alsa.nix index da92ed915b2..c72449150d1 100644 --- a/modules/services/audio/alsa.nix +++ b/modules/services/audio/alsa.nix @@ -1,8 +1,9 @@ # ALSA sound support. -{pkgs, config, ...}: +{ config, pkgs, ... }: + +with pkgs.lib; let - inherit (pkgs.lib) mkOption singleton mkIf; inherit (pkgs) alsaUtils; @@ -23,7 +24,7 @@ in description = '' Whether to enable ALSA sound. ''; - merge = pkgs.lib.mergeEnableOption; + merge = mergeEnableOption; }; }; @@ -44,10 +45,8 @@ in gid = config.ids.gids.audio; }; - jobs = singleton - { name = "alsa"; - - startOn = "udev"; + jobAttrs.alsa = + { startOn = "udev"; preStart = '' diff --git a/modules/services/databases/mysql.nix b/modules/services/databases/mysql.nix index 39b1978be91..9e7a0543c9d 100644 --- a/modules/services/databases/mysql.nix +++ b/modules/services/databases/mysql.nix @@ -1,7 +1,8 @@ -{pkgs, config, ...}: +{ config, pkgs, ... }: + +with pkgs.lib; let - inherit (pkgs.lib) mkOption mkIf singleton; cfg = config.services.mysql; @@ -71,9 +72,8 @@ in environment.systemPackages = [mysql]; - jobs = singleton - { name = "mysql"; - description = "MySQL server"; + jobAttrs.mysql = + { description = "MySQL server"; startOn = "filesystems"; stopOn = "shutdown"; diff --git a/modules/services/hardware/acpid.nix b/modules/services/hardware/acpid.nix index 10449aac216..595153b0af9 100644 --- a/modules/services/hardware/acpid.nix +++ b/modules/services/hardware/acpid.nix @@ -76,9 +76,8 @@ in config = mkIf config.powerManagement.enable { - jobs = singleton - { name = "acpid"; - description = "ACPI daemon"; + jobAttrs.acpid = + { description = "ACPI daemon"; startOn = "udev"; stopOn = "shutdown"; diff --git a/modules/services/hardware/hal.nix b/modules/services/hardware/hal.nix index 8948251f242..94831b62778 100644 --- a/modules/services/hardware/hal.nix +++ b/modules/services/hardware/hal.nix @@ -1,5 +1,5 @@ # HAL daemon. -{pkgs, config, ...}: +{ config, pkgs, ... }: with pkgs.lib; @@ -64,10 +64,8 @@ in gid = config.ids.gids.haldaemon; }; - jobs = singleton - { name = "hal"; - - description = "HAL daemon"; + jobAttrs.hal = + { description = "HAL daemon"; # !!! TODO: make sure that HAL starts after acpid, # otherwise hald-addon-acpi will grab /proc/acpi/event. diff --git a/modules/services/hardware/udev.nix b/modules/services/hardware/udev.nix index 16d05997fd3..91e933f4b03 100644 --- a/modules/services/hardware/udev.nix +++ b/modules/services/hardware/udev.nix @@ -152,10 +152,8 @@ in services.udev.packages = [extraUdevRules]; - jobs = singleton - { name = "udev"; - - startOn = "startup"; + jobAttrs.udev = + { startOn = "startup"; stopOn = "shutdown"; environment = { UDEV_CONFIG_FILE = conf; }; diff --git a/modules/services/logging/syslogd.nix b/modules/services/logging/syslogd.nix index f62bf1da33f..a1679f71bc2 100644 --- a/modules/services/logging/syslogd.nix +++ b/modules/services/logging/syslogd.nix @@ -47,10 +47,8 @@ in config = { - jobs = singleton - { name = "syslogd"; - - description = "Syslog daemon"; + jobAttrs.syslogd = + { description = "Syslog daemon"; startOn = "udev"; stopOn = "shutdown"; diff --git a/modules/services/misc/nix-daemon.nix b/modules/services/misc/nix-daemon.nix index d0c35d9130a..479c4fa4a28 100644 --- a/modules/services/misc/nix-daemon.nix +++ b/modules/services/misc/nix-daemon.nix @@ -1,4 +1,4 @@ -{pkgs, config, ...}: +{ config, pkgs, ... }: with pkgs.lib; @@ -127,7 +127,7 @@ in envVars = mkOption { internal = true; default = ""; - merge = pkgs.lib.mergeStringOption; + merge = mergeStringOption; description = " Environment variables used by Nix. "; @@ -178,7 +178,7 @@ in { # List of machines for distributed Nix builds in the format expected # by build-remote.pl. source = pkgs.writeText "nix.machines" - (pkgs.lib.concatStrings (map (machine: + (concatStrings (map (machine: "${machine.sshUser}@${machine.hostName} " + (if machine ? system then machine.system else concatStringsSep "," machine.systems) + " ${machine.sshKey} ${toString machine.maxJobs} " @@ -188,10 +188,8 @@ in target = "nix.machines"; }; - jobs = pkgs.lib.singleton - { name = "nix-daemon"; - - startOn = "startup"; + jobAttrs.nixDaemon = + { startOn = "startup"; script = '' diff --git a/modules/services/misc/rogue.nix b/modules/services/misc/rogue.nix index 3e6b24a5fd7..11d185f7409 100644 --- a/modules/services/misc/rogue.nix +++ b/modules/services/misc/rogue.nix @@ -40,10 +40,8 @@ in boot.extraTTYs = [ cfg.tty ]; - jobs = singleton - { name = "rogue"; - - description = "Rogue dungeon crawling game"; + jobAttrs.rogue = + { description = "Rogue dungeon crawling game"; startOn = "udev"; stopOn = "shutdown"; diff --git a/modules/services/networking/ddclient.nix b/modules/services/networking/ddclient.nix index 7d99a95131f..03172592c16 100644 --- a/modules/services/networking/ddclient.nix +++ b/modules/services/networking/ddclient.nix @@ -1,4 +1,4 @@ -{pkgs, config, ...}: +{ config, pkgs, ... }: let @@ -110,27 +110,24 @@ in home = stateDir; }; - jobs = singleton { + jobAttrs.ddclient = + { name = "ddclient"; - name = "ddclient"; + startOn = "startup"; + stopOn = "shutdown"; - startOn = "startup"; - stopOn = "shutdown"; + preStart = + '' + mkdir -m 0755 -p ${stateDir} + chown ${ddclientUser} ${stateDir} - preStart = '' - mkdir -m 0755 -p ${stateDir} - chown ${ddclientUser} ${stateDir} + # Needed to run ddclient as an unprivileged user. + ${modprobe}/sbin/modprobe capability || true + ''; - # Needed to run ddclient as an unprivileged user. - ${modprobe}/sbin/modprobe capability || true - ''; + exec = "${ddclient}/bin/ddclient ${ddclientFlags}"; + }; - script = '' - ${ddclient}/bin/ddclient ${ddclientFlags} - ''; - - }; - }; } diff --git a/modules/services/networking/dhclient.nix b/modules/services/networking/dhclient.nix index f1b523adf88..5ec87148172 100644 --- a/modules/services/networking/dhclient.nix +++ b/modules/services/networking/dhclient.nix @@ -1,7 +1,8 @@ -{pkgs, config, ...}: +{ config, pkgs, ... }: + +with pkgs.lib; let - inherit (pkgs.lib) mkOption mkIf mergeEnableOption mergeListOption; inherit (pkgs) nettools dhcp lib; @@ -60,10 +61,8 @@ in config = mkIf config.networking.useDHCP { - jobs = pkgs.lib.singleton - { name = "dhclient"; - - startOn = "network-interfaces/started"; + jobAttrs.dhclient = + { startOn = "network-interfaces/started"; stopOn = "network-interfaces/stop"; preStart = diff --git a/modules/services/networking/firewall.nix b/modules/services/networking/firewall.nix index f577f0e3bf1..f6353fdc37d 100644 --- a/modules/services/networking/firewall.nix +++ b/modules/services/networking/firewall.nix @@ -78,10 +78,8 @@ in environment.systemPackages = [pkgs.iptables]; - jobs = singleton - { name = "firewall"; - - startOn = "network-interfaces/started"; + jobAttrs.firewall = + { startOn = "network-interfaces/started"; preStart = '' diff --git a/modules/services/networking/privoxy.nix b/modules/services/networking/privoxy.nix index 4e2585aba81..4c8a50a5d70 100644 --- a/modules/services/networking/privoxy.nix +++ b/modules/services/networking/privoxy.nix @@ -1,9 +1,9 @@ -{pkgs, config, ...}: +{ config, pkgs, ... }: + +with pkgs.lib; let - inherit (pkgs.lib) mkOption mkIf singleton; - inherit (pkgs) privoxy; stateDir = "/var/spool/privoxy"; @@ -77,27 +77,24 @@ in home = stateDir; }; - jobs = singleton { + jobAttrs.privoxy = + { name = "privoxy"; - name = "privoxy"; + startOn = "startup"; + stopOn = "shutdown"; - startOn = "startup"; - stopOn = "shutdown"; + preStart = + '' + mkdir -m 0755 -p ${stateDir} + chown ${privoxyUser} ${stateDir} - preStart = '' - mkdir -m 0755 -p ${stateDir} - chown ${privoxyUser} ${stateDir} + # Needed to run privoxy as an unprivileged user. + ${modprobe}/sbin/modprobe capability || true + ''; - # Needed to run privoxy as an unprivileged user. - ${modprobe}/sbin/modprobe capability || true - ''; + exec = "${privoxy}/sbin/privoxy ${privoxyFlags}"; + }; - script = '' - ${privoxy}/sbin/privoxy ${privoxyFlags} - ''; - - }; - }; } diff --git a/modules/services/networking/wpa_supplicant.nix b/modules/services/networking/wpa_supplicant.nix index 309305481ee..c566452f9f7 100644 --- a/modules/services/networking/wpa_supplicant.nix +++ b/modules/services/networking/wpa_supplicant.nix @@ -1,4 +1,6 @@ -{pkgs, config, ...}: +{ config, pkgs, ... }: + +with pkgs.lib; let @@ -12,7 +14,7 @@ in options = { - networking.enableWLAN = pkgs.lib.mkOption { + networking.enableWLAN = mkOption { default = false; description = '' Whether to start wpa_supplicant to scan for @@ -31,14 +33,12 @@ in ###### implementation - config = pkgs.lib.mkIf config.networking.enableWLAN { + config = mkIf config.networking.enableWLAN { environment.systemPackages = [pkgs.wpa_supplicant]; - jobs = pkgs.lib.singleton - { name = "wpa_supplicant"; - - startOn = "network-interfaces/started"; + jobAttrs.wpa_supplicant = + { startOn = "network-interfaces/started"; stopOn = "network-interfaces/stop"; preStart = diff --git a/modules/services/networking/xinetd.nix b/modules/services/networking/xinetd.nix index a7f808e674e..41d6873d660 100644 --- a/modules/services/networking/xinetd.nix +++ b/modules/services/networking/xinetd.nix @@ -119,10 +119,8 @@ in config = mkIf cfg.enable { - jobs = singleton - { name = "xinetd"; - - description = "xinetd server"; + jobAttrs.xinetd = + { description = "xinetd server"; startOn = "network-interfaces/started"; stopOn = "network-interfaces/stop"; diff --git a/modules/services/scheduling/atd.nix b/modules/services/scheduling/atd.nix index 74fdd9ea84e..38e5dad6bd4 100644 --- a/modules/services/scheduling/atd.nix +++ b/modules/services/scheduling/atd.nix @@ -63,10 +63,8 @@ in gid = config.ids.gids.atd; }; - jobs = singleton - { name = "atd"; - - description = "at daemon (atd)"; + jobAttrs.atd = + { description = "at daemon (atd)"; startOn = "startup"; stopOn = "shutdown"; diff --git a/modules/services/system/dbus.nix b/modules/services/system/dbus.nix index 44d186dd54e..86c1887f57d 100644 --- a/modules/services/system/dbus.nix +++ b/modules/services/system/dbus.nix @@ -113,10 +113,8 @@ in gid = config.ids.gids.messagebus; }; - jobs = singleton - { name = "dbus"; - - startOn = "udev"; + jobAttrs.dbus = + { startOn = "udev"; stopOn = "shutdown"; preStart = diff --git a/modules/services/system/nscd.nix b/modules/services/system/nscd.nix index 11aa48720b2..3dfc6d3a468 100644 --- a/modules/services/system/nscd.nix +++ b/modules/services/system/nscd.nix @@ -17,10 +17,8 @@ in description = "Name service cache daemon user"; }; - jobs = singleton - { name = "nscd"; - - description = "Name Service Cache Daemon"; + jobAttrs.nscd = + { description = "Name Service Cache Daemon"; startOn = "startup"; stopOn = "shutdown"; diff --git a/modules/services/ttys/mingetty.nix b/modules/services/ttys/mingetty.nix index d4cade43f40..bbe3dd38c78 100644 --- a/modules/services/ttys/mingetty.nix +++ b/modules/services/ttys/mingetty.nix @@ -1,10 +1,6 @@ -{pkgs, config, ...}: +{ config, pkgs, ... }: -let - - inherit (pkgs.lib) mkOption mkIf singleton; - -in +with pkgs.lib; { @@ -57,15 +53,13 @@ in config = { # Generate a separate job for each tty. - jobs = map (tty: { + jobAttrs = listToAttrs (map (tty: nameValuePair tty { - name = tty; - startOn = "udev"; exec = "${pkgs.mingetty}/sbin/mingetty --loginprog=${pkgs.pam_login}/bin/login --noclear ${tty}"; - }) config.services.mingetty.ttys; + }) config.services.mingetty.ttys); environment.etc = singleton { # Friendly greeting on the virtual consoles. diff --git a/modules/services/x11/xserver.nix b/modules/services/x11/xserver.nix index eff5b693722..cbfcfbd186b 100644 --- a/modules/services/x11/xserver.nix +++ b/modules/services/x11/xserver.nix @@ -348,10 +348,8 @@ in services.hal.packages = halConfigFiles; - jobs = singleton - { name = "xserver"; - - startOn = if cfg.autorun then "hal" else "never"; + jobAttrs.xserver = + { startOn = if cfg.autorun then "hal" else "never"; environment = { FONTCONFIG_FILE = "/etc/fonts/fonts.conf"; # !!! cleanup diff --git a/modules/system/upstart/upstart.nix b/modules/system/upstart/upstart.nix index f84d98ff873..efa5d52ae7b 100644 --- a/modules/system/upstart/upstart.nix +++ b/modules/system/upstart/upstart.nix @@ -73,7 +73,7 @@ let echo "$jobText" > $out/etc/event.d/${job.name} ''; - + jobs = let deprecatedJobDefs = config.jobs; diff --git a/modules/tasks/kbd.nix b/modules/tasks/kbd.nix index fb95712bf11..d1c9e4bab35 100644 --- a/modules/tasks/kbd.nix +++ b/modules/tasks/kbd.nix @@ -1,4 +1,4 @@ -{pkgs, config, ...}: +{ config, pkgs, ... }: with pkgs.lib; @@ -56,10 +56,8 @@ in environment.systemPackages = [pkgs.kbd]; - jobs = singleton - { name = "kbd"; - - description = "Keyboard / console initialisation"; + jobAttrs.kbd = + { description = "Keyboard / console initialisation"; startOn = "udev"; diff --git a/modules/tasks/network-interfaces.nix b/modules/tasks/network-interfaces.nix index 713eed22e88..50c2c73823d 100644 --- a/modules/tasks/network-interfaces.nix +++ b/modules/tasks/network-interfaces.nix @@ -1,9 +1,9 @@ -{pkgs, config, ...}: +{ config, pkgs, ... }: + +with pkgs.lib; let - inherit (pkgs.lib) mkOption types; - inherit (pkgs) nettools; cfg = config.networking; @@ -132,7 +132,7 @@ in pkgs.wirelesstools ]; - jobs = pkgs.lib.singleton + jobAttrs.networkInterfaces = { name = "network-interfaces"; startOn = "udev"; diff --git a/modules/tasks/swap.nix b/modules/tasks/swap.nix index 0f1a726ab29..ae4cd3a5c49 100644 --- a/modules/tasks/swap.nix +++ b/modules/tasks/swap.nix @@ -1,9 +1,10 @@ -{pkgs, config, ...}: +{ config, pkgs, ... }: + +with pkgs.lib; let inherit (pkgs) utillinux; - inherit (pkgs.lib) mkOption filter types; toPath = x: if x.device != null then x.device else "/dev/disk/by-label/${x.label}"; @@ -65,10 +66,8 @@ in config = { - jobs = pkgs.lib.singleton - { name = "swap"; - - task = true; + jobAttrs.swap = + { task = true; startOn = ["startup" "new-devices"]; diff --git a/modules/tasks/tty-backgrounds.nix b/modules/tasks/tty-backgrounds.nix index 5e3631f9adb..2abcf068e41 100644 --- a/modules/tasks/tty-backgrounds.nix +++ b/modules/tasks/tty-backgrounds.nix @@ -1,7 +1,9 @@ -{pkgs, config, ...}: +{ config, pkgs, ... }: + +with pkgs.lib; let - inherit (pkgs.lib) mkOption mkIf singleton; + inherit (pkgs) stdenv; kernelPackages = config.boot.kernelPackages; @@ -19,7 +21,7 @@ let # syslog tty, except those for which a specific theme is # specified. defaultTTYs = - pkgs.lib.filter (x: !(pkgs.lib.elem x overridenTTYs)) requiredTTYs; + filter (x: !(elem x overridenTTYs)) requiredTTYs; in (map (tty: { @@ -100,42 +102,42 @@ in target = "splash"; }; - jobs = singleton { - name = "tty-backgrounds"; + jobAttrs.ttyBackgrounds = + { name = "tty-backgrounds"; - startOn = "udev"; + startOn = "udev"; - preStart = - '' - # Critical: tell the kernel where to find splash_helper. It calls - # this program every time we switch between consoles. - helperProcFile=${splashutils.helperProcFile} - if test -e /proc/sys/fbcondecor; then helperProcFile=/proc/sys/fbcondecor; fi - echo ${splashutils}/${splashutils.helperName} > $helperProcFile + preStart = + '' + # Critical: tell the kernel where to find splash_helper. It calls + # this program every time we switch between consoles. + helperProcFile=${splashutils.helperProcFile} + if test -e /proc/sys/fbcondecor; then helperProcFile=/proc/sys/fbcondecor; fi + echo ${splashutils}/${splashutils.helperName} > $helperProcFile - # For each console... - for tty in ${toString (map (x: x.tty) backgrounds)}; do - # Make sure that the console exists. - echo -n "" > /dev/$tty + # For each console... + for tty in ${toString (map (x: x.tty) backgrounds)}; do + # Make sure that the console exists. + echo -n "" > /dev/$tty - # Set the theme as determined by tty-backgrounds-combine.sh - # above. Note that splashutils needs a TTY number - # instead of a device name, hence the ''${tty:3}. - theme=$(readlink ${themesUnpacked}/$tty) - ${splashutils}/${splashutils.controlName} --tty ''${tty:3} -c setcfg -t $theme || true - ${splashutils}/${splashutils.controlName} --tty ''${tty:3} -c setpic -t $theme || true - ${splashutils}/${splashutils.controlName} --tty ''${tty:3} -c on || true - done - ''; + # Set the theme as determined by tty-backgrounds-combine.sh + # above. Note that splashutils needs a TTY number + # instead of a device name, hence the ''${tty:3}. + theme=$(readlink ${themesUnpacked}/$tty) + ${splashutils}/${splashutils.controlName} --tty ''${tty:3} -c setcfg -t $theme || true + ${splashutils}/${splashutils.controlName} --tty ''${tty:3} -c setpic -t $theme || true + ${splashutils}/${splashutils.controlName} --tty ''${tty:3} -c on || true + done + ''; - postStop = - '' - # Disable the theme on each console. - for tty in ${toString (map (x: x.tty) backgrounds)}; do - ${splashutils}/${splashutils.controlName} --tty ''${tty:3} -c off || true - done - ''; - }; + postStop = + '' + # Disable the theme on each console. + for tty in ${toString (map (x: x.tty) backgrounds)}; do + ${splashutils}/${splashutils.controlName} --tty ''${tty:3} -c off || true + done + ''; + }; }; diff --git a/modules/testing/test-instrumentation.nix b/modules/testing/test-instrumentation.nix index 85f892e887f..a3c874d4fa5 100644 --- a/modules/testing/test-instrumentation.nix +++ b/modules/testing/test-instrumentation.nix @@ -9,10 +9,8 @@ with pkgs.lib; config = { - jobs = singleton - { name = "backdoor"; - - startOn = "network-interfaces"; + jobAttrs.backdoor = + { startOn = "network-interfaces"; preStart = ''