* Convert the remaining jobs to jobAttrs style.

svn path=/nixos/trunk/; revision=17764
This commit is contained in:
Eelco Dolstra 2009-10-12 17:27:57 +00:00
parent 9943e0762e
commit d982f23f20
25 changed files with 136 additions and 176 deletions

View file

@ -1,8 +1,9 @@
# ALSA sound support. # ALSA sound support.
{pkgs, config, ...}: { config, pkgs, ... }:
with pkgs.lib;
let let
inherit (pkgs.lib) mkOption singleton mkIf;
inherit (pkgs) alsaUtils; inherit (pkgs) alsaUtils;
@ -23,7 +24,7 @@ in
description = '' description = ''
Whether to enable ALSA sound. Whether to enable ALSA sound.
''; '';
merge = pkgs.lib.mergeEnableOption; merge = mergeEnableOption;
}; };
}; };
@ -44,10 +45,8 @@ in
gid = config.ids.gids.audio; gid = config.ids.gids.audio;
}; };
jobs = singleton jobAttrs.alsa =
{ name = "alsa"; { startOn = "udev";
startOn = "udev";
preStart = preStart =
'' ''

View file

@ -1,7 +1,8 @@
{pkgs, config, ...}: { config, pkgs, ... }:
with pkgs.lib;
let let
inherit (pkgs.lib) mkOption mkIf singleton;
cfg = config.services.mysql; cfg = config.services.mysql;
@ -71,9 +72,8 @@ in
environment.systemPackages = [mysql]; environment.systemPackages = [mysql];
jobs = singleton jobAttrs.mysql =
{ name = "mysql"; { description = "MySQL server";
description = "MySQL server";
startOn = "filesystems"; startOn = "filesystems";
stopOn = "shutdown"; stopOn = "shutdown";

View file

@ -76,9 +76,8 @@ in
config = mkIf config.powerManagement.enable { config = mkIf config.powerManagement.enable {
jobs = singleton jobAttrs.acpid =
{ name = "acpid"; { description = "ACPI daemon";
description = "ACPI daemon";
startOn = "udev"; startOn = "udev";
stopOn = "shutdown"; stopOn = "shutdown";

View file

@ -1,5 +1,5 @@
# HAL daemon. # HAL daemon.
{pkgs, config, ...}: { config, pkgs, ... }:
with pkgs.lib; with pkgs.lib;
@ -64,10 +64,8 @@ in
gid = config.ids.gids.haldaemon; gid = config.ids.gids.haldaemon;
}; };
jobs = singleton jobAttrs.hal =
{ name = "hal"; { description = "HAL daemon";
description = "HAL daemon";
# !!! TODO: make sure that HAL starts after acpid, # !!! TODO: make sure that HAL starts after acpid,
# otherwise hald-addon-acpi will grab /proc/acpi/event. # otherwise hald-addon-acpi will grab /proc/acpi/event.

View file

@ -152,10 +152,8 @@ in
services.udev.packages = [extraUdevRules]; services.udev.packages = [extraUdevRules];
jobs = singleton jobAttrs.udev =
{ name = "udev"; { startOn = "startup";
startOn = "startup";
stopOn = "shutdown"; stopOn = "shutdown";
environment = { UDEV_CONFIG_FILE = conf; }; environment = { UDEV_CONFIG_FILE = conf; };

View file

@ -47,10 +47,8 @@ in
config = { config = {
jobs = singleton jobAttrs.syslogd =
{ name = "syslogd"; { description = "Syslog daemon";
description = "Syslog daemon";
startOn = "udev"; startOn = "udev";
stopOn = "shutdown"; stopOn = "shutdown";

View file

@ -1,4 +1,4 @@
{pkgs, config, ...}: { config, pkgs, ... }:
with pkgs.lib; with pkgs.lib;
@ -127,7 +127,7 @@ in
envVars = mkOption { envVars = mkOption {
internal = true; internal = true;
default = ""; default = "";
merge = pkgs.lib.mergeStringOption; merge = mergeStringOption;
description = " description = "
Environment variables used by Nix. Environment variables used by Nix.
"; ";
@ -178,7 +178,7 @@ in
{ # List of machines for distributed Nix builds in the format expected { # List of machines for distributed Nix builds in the format expected
# by build-remote.pl. # by build-remote.pl.
source = pkgs.writeText "nix.machines" source = pkgs.writeText "nix.machines"
(pkgs.lib.concatStrings (map (machine: (concatStrings (map (machine:
"${machine.sshUser}@${machine.hostName} " "${machine.sshUser}@${machine.hostName} "
+ (if machine ? system then machine.system else concatStringsSep "," machine.systems) + (if machine ? system then machine.system else concatStringsSep "," machine.systems)
+ " ${machine.sshKey} ${toString machine.maxJobs} " + " ${machine.sshKey} ${toString machine.maxJobs} "
@ -188,10 +188,8 @@ in
target = "nix.machines"; target = "nix.machines";
}; };
jobs = pkgs.lib.singleton jobAttrs.nixDaemon =
{ name = "nix-daemon"; { startOn = "startup";
startOn = "startup";
script = script =
'' ''

View file

@ -40,10 +40,8 @@ in
boot.extraTTYs = [ cfg.tty ]; boot.extraTTYs = [ cfg.tty ];
jobs = singleton jobAttrs.rogue =
{ name = "rogue"; { description = "Rogue dungeon crawling game";
description = "Rogue dungeon crawling game";
startOn = "udev"; startOn = "udev";
stopOn = "shutdown"; stopOn = "shutdown";

View file

@ -1,4 +1,4 @@
{pkgs, config, ...}: { config, pkgs, ... }:
let let
@ -110,27 +110,24 @@ in
home = stateDir; home = stateDir;
}; };
jobs = singleton { jobAttrs.ddclient =
{ name = "ddclient";
name = "ddclient"; startOn = "startup";
stopOn = "shutdown";
startOn = "startup"; preStart =
stopOn = "shutdown"; ''
mkdir -m 0755 -p ${stateDir}
chown ${ddclientUser} ${stateDir}
preStart = '' # Needed to run ddclient as an unprivileged user.
mkdir -m 0755 -p ${stateDir} ${modprobe}/sbin/modprobe capability || true
chown ${ddclientUser} ${stateDir} '';
# Needed to run ddclient as an unprivileged user. exec = "${ddclient}/bin/ddclient ${ddclientFlags}";
${modprobe}/sbin/modprobe capability || true };
'';
script = ''
${ddclient}/bin/ddclient ${ddclientFlags}
'';
};
}; };
} }

View file

@ -1,7 +1,8 @@
{pkgs, config, ...}: { config, pkgs, ... }:
with pkgs.lib;
let let
inherit (pkgs.lib) mkOption mkIf mergeEnableOption mergeListOption;
inherit (pkgs) nettools dhcp lib; inherit (pkgs) nettools dhcp lib;
@ -60,10 +61,8 @@ in
config = mkIf config.networking.useDHCP { config = mkIf config.networking.useDHCP {
jobs = pkgs.lib.singleton jobAttrs.dhclient =
{ name = "dhclient"; { startOn = "network-interfaces/started";
startOn = "network-interfaces/started";
stopOn = "network-interfaces/stop"; stopOn = "network-interfaces/stop";
preStart = preStart =

View file

@ -78,10 +78,8 @@ in
environment.systemPackages = [pkgs.iptables]; environment.systemPackages = [pkgs.iptables];
jobs = singleton jobAttrs.firewall =
{ name = "firewall"; { startOn = "network-interfaces/started";
startOn = "network-interfaces/started";
preStart = preStart =
'' ''

View file

@ -1,9 +1,9 @@
{pkgs, config, ...}: { config, pkgs, ... }:
with pkgs.lib;
let let
inherit (pkgs.lib) mkOption mkIf singleton;
inherit (pkgs) privoxy; inherit (pkgs) privoxy;
stateDir = "/var/spool/privoxy"; stateDir = "/var/spool/privoxy";
@ -77,27 +77,24 @@ in
home = stateDir; home = stateDir;
}; };
jobs = singleton { jobAttrs.privoxy =
{ name = "privoxy";
name = "privoxy"; startOn = "startup";
stopOn = "shutdown";
startOn = "startup"; preStart =
stopOn = "shutdown"; ''
mkdir -m 0755 -p ${stateDir}
chown ${privoxyUser} ${stateDir}
preStart = '' # Needed to run privoxy as an unprivileged user.
mkdir -m 0755 -p ${stateDir} ${modprobe}/sbin/modprobe capability || true
chown ${privoxyUser} ${stateDir} '';
# Needed to run privoxy as an unprivileged user. exec = "${privoxy}/sbin/privoxy ${privoxyFlags}";
${modprobe}/sbin/modprobe capability || true };
'';
script = ''
${privoxy}/sbin/privoxy ${privoxyFlags}
'';
};
}; };
} }

View file

@ -1,4 +1,6 @@
{pkgs, config, ...}: { config, pkgs, ... }:
with pkgs.lib;
let let
@ -12,7 +14,7 @@ in
options = { options = {
networking.enableWLAN = pkgs.lib.mkOption { networking.enableWLAN = mkOption {
default = false; default = false;
description = '' description = ''
Whether to start <command>wpa_supplicant</command> to scan for Whether to start <command>wpa_supplicant</command> to scan for
@ -31,14 +33,12 @@ in
###### implementation ###### implementation
config = pkgs.lib.mkIf config.networking.enableWLAN { config = mkIf config.networking.enableWLAN {
environment.systemPackages = [pkgs.wpa_supplicant]; environment.systemPackages = [pkgs.wpa_supplicant];
jobs = pkgs.lib.singleton jobAttrs.wpa_supplicant =
{ name = "wpa_supplicant"; { startOn = "network-interfaces/started";
startOn = "network-interfaces/started";
stopOn = "network-interfaces/stop"; stopOn = "network-interfaces/stop";
preStart = preStart =

View file

@ -119,10 +119,8 @@ in
config = mkIf cfg.enable { config = mkIf cfg.enable {
jobs = singleton jobAttrs.xinetd =
{ name = "xinetd"; { description = "xinetd server";
description = "xinetd server";
startOn = "network-interfaces/started"; startOn = "network-interfaces/started";
stopOn = "network-interfaces/stop"; stopOn = "network-interfaces/stop";

View file

@ -63,10 +63,8 @@ in
gid = config.ids.gids.atd; gid = config.ids.gids.atd;
}; };
jobs = singleton jobAttrs.atd =
{ name = "atd"; { description = "at daemon (atd)";
description = "at daemon (atd)";
startOn = "startup"; startOn = "startup";
stopOn = "shutdown"; stopOn = "shutdown";

View file

@ -113,10 +113,8 @@ in
gid = config.ids.gids.messagebus; gid = config.ids.gids.messagebus;
}; };
jobs = singleton jobAttrs.dbus =
{ name = "dbus"; { startOn = "udev";
startOn = "udev";
stopOn = "shutdown"; stopOn = "shutdown";
preStart = preStart =

View file

@ -17,10 +17,8 @@ in
description = "Name service cache daemon user"; description = "Name service cache daemon user";
}; };
jobs = singleton jobAttrs.nscd =
{ name = "nscd"; { description = "Name Service Cache Daemon";
description = "Name Service Cache Daemon";
startOn = "startup"; startOn = "startup";
stopOn = "shutdown"; stopOn = "shutdown";

View file

@ -1,10 +1,6 @@
{pkgs, config, ...}: { config, pkgs, ... }:
let with pkgs.lib;
inherit (pkgs.lib) mkOption mkIf singleton;
in
{ {
@ -57,15 +53,13 @@ in
config = { config = {
# Generate a separate job for each tty. # Generate a separate job for each tty.
jobs = map (tty: { jobAttrs = listToAttrs (map (tty: nameValuePair tty {
name = tty;
startOn = "udev"; startOn = "udev";
exec = "${pkgs.mingetty}/sbin/mingetty --loginprog=${pkgs.pam_login}/bin/login --noclear ${tty}"; exec = "${pkgs.mingetty}/sbin/mingetty --loginprog=${pkgs.pam_login}/bin/login --noclear ${tty}";
}) config.services.mingetty.ttys; }) config.services.mingetty.ttys);
environment.etc = singleton environment.etc = singleton
{ # Friendly greeting on the virtual consoles. { # Friendly greeting on the virtual consoles.

View file

@ -348,10 +348,8 @@ in
services.hal.packages = halConfigFiles; services.hal.packages = halConfigFiles;
jobs = singleton jobAttrs.xserver =
{ name = "xserver"; { startOn = if cfg.autorun then "hal" else "never";
startOn = if cfg.autorun then "hal" else "never";
environment = environment =
{ FONTCONFIG_FILE = "/etc/fonts/fonts.conf"; # !!! cleanup { FONTCONFIG_FILE = "/etc/fonts/fonts.conf"; # !!! cleanup

View file

@ -73,7 +73,7 @@ let
echo "$jobText" > $out/etc/event.d/${job.name} echo "$jobText" > $out/etc/event.d/${job.name}
''; '';
jobs = jobs =
let let
deprecatedJobDefs = config.jobs; deprecatedJobDefs = config.jobs;

View file

@ -1,4 +1,4 @@
{pkgs, config, ...}: { config, pkgs, ... }:
with pkgs.lib; with pkgs.lib;
@ -56,10 +56,8 @@ in
environment.systemPackages = [pkgs.kbd]; environment.systemPackages = [pkgs.kbd];
jobs = singleton jobAttrs.kbd =
{ name = "kbd"; { description = "Keyboard / console initialisation";
description = "Keyboard / console initialisation";
startOn = "udev"; startOn = "udev";

View file

@ -1,9 +1,9 @@
{pkgs, config, ...}: { config, pkgs, ... }:
with pkgs.lib;
let let
inherit (pkgs.lib) mkOption types;
inherit (pkgs) nettools; inherit (pkgs) nettools;
cfg = config.networking; cfg = config.networking;
@ -132,7 +132,7 @@ in
pkgs.wirelesstools pkgs.wirelesstools
]; ];
jobs = pkgs.lib.singleton jobAttrs.networkInterfaces =
{ name = "network-interfaces"; { name = "network-interfaces";
startOn = "udev"; startOn = "udev";

View file

@ -1,9 +1,10 @@
{pkgs, config, ...}: { config, pkgs, ... }:
with pkgs.lib;
let let
inherit (pkgs) utillinux; 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}"; toPath = x: if x.device != null then x.device else "/dev/disk/by-label/${x.label}";
@ -65,10 +66,8 @@ in
config = { config = {
jobs = pkgs.lib.singleton jobAttrs.swap =
{ name = "swap"; { task = true;
task = true;
startOn = ["startup" "new-devices"]; startOn = ["startup" "new-devices"];

View file

@ -1,7 +1,9 @@
{pkgs, config, ...}: { config, pkgs, ... }:
with pkgs.lib;
let let
inherit (pkgs.lib) mkOption mkIf singleton;
inherit (pkgs) stdenv; inherit (pkgs) stdenv;
kernelPackages = config.boot.kernelPackages; kernelPackages = config.boot.kernelPackages;
@ -19,7 +21,7 @@ let
# syslog tty, except those for which a specific theme is # syslog tty, except those for which a specific theme is
# specified. # specified.
defaultTTYs = defaultTTYs =
pkgs.lib.filter (x: !(pkgs.lib.elem x overridenTTYs)) requiredTTYs; filter (x: !(elem x overridenTTYs)) requiredTTYs;
in in
(map (tty: { (map (tty: {
@ -100,42 +102,42 @@ in
target = "splash"; target = "splash";
}; };
jobs = singleton { jobAttrs.ttyBackgrounds =
name = "tty-backgrounds"; { name = "tty-backgrounds";
startOn = "udev"; startOn = "udev";
preStart = preStart =
'' ''
# Critical: tell the kernel where to find splash_helper. It calls # Critical: tell the kernel where to find splash_helper. It calls
# this program every time we switch between consoles. # this program every time we switch between consoles.
helperProcFile=${splashutils.helperProcFile} helperProcFile=${splashutils.helperProcFile}
if test -e /proc/sys/fbcondecor; then helperProcFile=/proc/sys/fbcondecor; fi if test -e /proc/sys/fbcondecor; then helperProcFile=/proc/sys/fbcondecor; fi
echo ${splashutils}/${splashutils.helperName} > $helperProcFile echo ${splashutils}/${splashutils.helperName} > $helperProcFile
# For each console... # For each console...
for tty in ${toString (map (x: x.tty) backgrounds)}; do for tty in ${toString (map (x: x.tty) backgrounds)}; do
# Make sure that the console exists. # Make sure that the console exists.
echo -n "" > /dev/$tty echo -n "" > /dev/$tty
# Set the theme as determined by tty-backgrounds-combine.sh # Set the theme as determined by tty-backgrounds-combine.sh
# above. Note that splashutils needs a TTY number # above. Note that splashutils needs a TTY number
# instead of a device name, hence the ''${tty:3}. # instead of a device name, hence the ''${tty:3}.
theme=$(readlink ${themesUnpacked}/$tty) theme=$(readlink ${themesUnpacked}/$tty)
${splashutils}/${splashutils.controlName} --tty ''${tty:3} -c setcfg -t $theme || true ${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 setpic -t $theme || true
${splashutils}/${splashutils.controlName} --tty ''${tty:3} -c on || true ${splashutils}/${splashutils.controlName} --tty ''${tty:3} -c on || true
done done
''; '';
postStop = postStop =
'' ''
# Disable the theme on each console. # Disable the theme on each console.
for tty in ${toString (map (x: x.tty) backgrounds)}; do for tty in ${toString (map (x: x.tty) backgrounds)}; do
${splashutils}/${splashutils.controlName} --tty ''${tty:3} -c off || true ${splashutils}/${splashutils.controlName} --tty ''${tty:3} -c off || true
done done
''; '';
}; };
}; };

View file

@ -9,10 +9,8 @@ with pkgs.lib;
config = { config = {
jobs = singleton jobAttrs.backdoor =
{ name = "backdoor"; { startOn = "network-interfaces";
startOn = "network-interfaces";
preStart = preStart =
'' ''