* 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.
{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 =
''

View File

@ -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";

View File

@ -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";

View File

@ -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.

View File

@ -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; };

View File

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

View File

@ -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 =
''

View File

@ -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";

View File

@ -1,4 +1,4 @@
{pkgs, config, ...}:
{ config, pkgs, ... }:
let
@ -110,26 +110,23 @@ 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
'';
script = ''
${ddclient}/bin/ddclient ${ddclientFlags}
'';
};
exec = "${ddclient}/bin/ddclient ${ddclientFlags}";
};
};

View File

@ -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 =

View File

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

View File

@ -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,26 +77,23 @@ 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
'';
script = ''
${privoxy}/sbin/privoxy ${privoxyFlags}
'';
};
exec = "${privoxy}/sbin/privoxy ${privoxyFlags}";
};
};

View File

@ -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 <command>wpa_supplicant</command> 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 =

View File

@ -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";

View File

@ -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";

View File

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

View File

@ -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";

View File

@ -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: {
name = tty;
jobAttrs = listToAttrs (map (tty: nameValuePair 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.

View File

@ -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

View File

@ -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";

View File

@ -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";

View File

@ -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"];

View File

@ -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
'';
};
};

View File

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