2008-12-04 15:48:27 +00:00
|
|
|
{config, pkgs, ...}:
|
2008-11-18 18:00:09 +00:00
|
|
|
|
|
|
|
###### interface
|
|
|
|
let
|
2008-12-07 12:27:46 +00:00
|
|
|
inherit (pkgs.lib) mkOption mapAttrs getAttr fold
|
|
|
|
mergeListOption mergeTypedOption mergeAttrsWithFunc;
|
|
|
|
|
2008-11-18 18:00:09 +00:00
|
|
|
options = {
|
|
|
|
services = {
|
|
|
|
extraJobs = mkOption {
|
|
|
|
default = [];
|
|
|
|
example = [
|
|
|
|
{ name = "test-job";
|
|
|
|
job = ''
|
|
|
|
description "nc"
|
|
|
|
start on started network-interfaces
|
|
|
|
respawn
|
|
|
|
env PATH=/var/run/current-system/sw/bin
|
|
|
|
exec sh -c "echo 'hello world' | ${pkgs.netcat}/bin/nc -l -p 9000"
|
|
|
|
'';
|
|
|
|
} ];
|
|
|
|
# should have some checks to everify the syntax
|
|
|
|
merge = pkgs.lib.mergeListOption;
|
|
|
|
description = "
|
|
|
|
Additional Upstart jobs.
|
|
|
|
";
|
|
|
|
};
|
2008-12-07 12:27:46 +00:00
|
|
|
|
2009-01-02 16:06:41 +00:00
|
|
|
tools = {
|
|
|
|
upstartJobs = mkOption {
|
|
|
|
default = {};
|
|
|
|
description = "
|
|
|
|
List of functions which can be used to create upstart-jobs.
|
|
|
|
";
|
2008-12-07 12:27:46 +00:00
|
|
|
};
|
|
|
|
};
|
2008-11-18 18:00:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
tests = {
|
|
|
|
upstartJobs = mkOption {
|
|
|
|
internal = true;
|
|
|
|
default = {};
|
|
|
|
description = "
|
|
|
|
Make it easier to build individual Upstart jobs. (e.g.,
|
|
|
|
<command>nix-build /etc/nixos/nixos -A
|
|
|
|
tests.upstartJobs.xserver</command>).
|
|
|
|
";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
in
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
let
|
|
|
|
# should be moved to the corresponding jobs.
|
|
|
|
nix = config.environment.nix;
|
|
|
|
nixEnvVars = config.nix.envVars;
|
|
|
|
kernelPackages = config.boot.kernelPackages;
|
|
|
|
nssModulesPath = config.system.nssModules.path;
|
|
|
|
modprobe = config.system.sbin.modprobe;
|
|
|
|
mount = config.system.sbin.mount;
|
2006-12-11 15:32:10 +00:00
|
|
|
|
|
|
|
makeJob = import ../upstart-jobs/make-job.nix {
|
|
|
|
inherit (pkgs) runCommand;
|
|
|
|
};
|
|
|
|
|
2007-11-09 18:49:45 +00:00
|
|
|
optional = cond: service: pkgs.lib.optional cond (makeJob service);
|
2006-12-16 18:24:49 +00:00
|
|
|
|
2009-03-06 12:25:38 +00:00
|
|
|
requiredTTYs = config.requiredTTYs;
|
2007-04-04 17:10:38 +00:00
|
|
|
|
2008-03-16 01:05:40 +00:00
|
|
|
jobs = map makeJob
|
2009-03-05 17:11:40 +00:00
|
|
|
([
|
2008-05-08 12:27:01 +00:00
|
|
|
|
2008-05-08 13:47:44 +00:00
|
|
|
# Klogd.
|
|
|
|
(import ../upstart-jobs/klogd.nix {
|
|
|
|
inherit (pkgs) sysklogd writeText;
|
|
|
|
inherit config;
|
|
|
|
})
|
|
|
|
|
2006-12-13 12:17:38 +00:00
|
|
|
# The udev daemon creates devices nodes and runs programs when
|
|
|
|
# hardware events occur.
|
|
|
|
(import ../upstart-jobs/udev.nix {
|
2008-07-03 10:45:14 +00:00
|
|
|
inherit modprobe config;
|
2007-03-03 23:20:08 +00:00
|
|
|
inherit (pkgs) stdenv writeText substituteAll udev procps;
|
2007-01-15 09:20:34 +00:00
|
|
|
inherit (pkgs.lib) cleanSource;
|
2009-01-25 15:48:59 +00:00
|
|
|
firmwareDirs = config.services.udev.addFirmware;
|
|
|
|
extraUdevPkgs = config.services.udev.addUdevPkgs;
|
2006-12-13 12:17:38 +00:00
|
|
|
})
|
|
|
|
|
2006-12-24 01:07:28 +00:00
|
|
|
# Makes LVM logical volumes available.
|
|
|
|
(import ../upstart-jobs/lvm.nix {
|
2007-03-04 01:16:24 +00:00
|
|
|
inherit modprobe;
|
2007-06-28 09:57:36 +00:00
|
|
|
inherit (pkgs) lvm2 devicemapper;
|
2006-12-24 01:07:28 +00:00
|
|
|
})
|
|
|
|
|
2007-01-11 00:40:28 +00:00
|
|
|
# Activate software RAID arrays.
|
|
|
|
(import ../upstart-jobs/swraid.nix {
|
2007-03-04 01:16:24 +00:00
|
|
|
inherit modprobe;
|
|
|
|
inherit (pkgs) mdadm;
|
2007-01-11 00:40:28 +00:00
|
|
|
})
|
|
|
|
|
2006-12-21 14:22:40 +00:00
|
|
|
# Mount file systems.
|
|
|
|
(import ../upstart-jobs/filesystems.nix {
|
2008-08-09 12:03:08 +00:00
|
|
|
inherit mount;
|
2006-12-21 20:08:15 +00:00
|
|
|
inherit (pkgs) utillinux e2fsprogs;
|
2007-11-09 18:49:45 +00:00
|
|
|
fileSystems = config.fileSystems;
|
2006-12-21 14:22:40 +00:00
|
|
|
})
|
|
|
|
|
2006-12-21 01:07:23 +00:00
|
|
|
# Swapping.
|
|
|
|
(import ../upstart-jobs/swap.nix {
|
2008-02-11 11:51:51 +00:00
|
|
|
inherit (pkgs) utillinux lib;
|
2007-11-09 18:49:45 +00:00
|
|
|
swapDevices = config.swapDevices;
|
2006-12-21 01:07:23 +00:00
|
|
|
})
|
|
|
|
|
2006-12-11 15:32:10 +00:00
|
|
|
# Network interfaces.
|
|
|
|
(import ../upstart-jobs/network-interfaces.nix {
|
2007-11-23 17:12:37 +00:00
|
|
|
inherit modprobe config;
|
2007-05-24 14:50:17 +00:00
|
|
|
inherit (pkgs) nettools wirelesstools bash writeText;
|
2006-12-11 15:32:10 +00:00
|
|
|
})
|
|
|
|
|
2007-01-11 23:55:25 +00:00
|
|
|
# Name service cache daemon.
|
|
|
|
(import ../upstart-jobs/nscd.nix {
|
2007-06-10 20:13:12 +00:00
|
|
|
inherit (pkgs) glibc;
|
2007-01-15 17:19:41 +00:00
|
|
|
inherit nssModulesPath;
|
2007-01-11 23:55:25 +00:00
|
|
|
})
|
|
|
|
|
2006-12-11 15:32:10 +00:00
|
|
|
# Handles the maintenance/stalled event (single-user shell).
|
|
|
|
(import ../upstart-jobs/maintenance-shell.nix {
|
|
|
|
inherit (pkgs) bash;
|
|
|
|
})
|
|
|
|
|
|
|
|
# Ctrl-alt-delete action.
|
|
|
|
(import ../upstart-jobs/ctrl-alt-delete.nix)
|
|
|
|
|
2008-03-16 01:05:40 +00:00
|
|
|
])
|
2006-12-11 15:32:10 +00:00
|
|
|
|
2007-08-14 16:43:56 +00:00
|
|
|
# ifplugd daemon for monitoring Ethernet cables.
|
2007-11-09 18:49:45 +00:00
|
|
|
++ optional config.networking.interfaceMonitor.enable
|
2007-08-14 16:43:56 +00:00
|
|
|
(import ../upstart-jobs/ifplugd.nix {
|
|
|
|
inherit (pkgs) ifplugd writeScript bash;
|
|
|
|
inherit config;
|
|
|
|
})
|
|
|
|
|
2008-09-04 20:28:02 +00:00
|
|
|
# GNUnet daemon.
|
|
|
|
++ optional config.services.gnunet.enable
|
|
|
|
(import ../upstart-jobs/gnunet.nix {
|
|
|
|
inherit (pkgs) gnunet lib writeText;
|
|
|
|
gnunetConfig = config.services.gnunet;
|
|
|
|
})
|
|
|
|
|
2006-12-18 19:20:03 +00:00
|
|
|
# Apache httpd.
|
2008-02-04 10:52:58 +00:00
|
|
|
++ optional (config.services.httpd.enable && !config.services.httpd.experimental)
|
2006-12-18 19:20:03 +00:00
|
|
|
(import ../upstart-jobs/httpd.nix {
|
2006-12-18 19:46:48 +00:00
|
|
|
inherit config pkgs;
|
2007-06-10 20:13:12 +00:00
|
|
|
inherit (pkgs) glibc;
|
2007-11-23 10:56:12 +00:00
|
|
|
extraConfig = pkgs.lib.concatStringsSep "\n"
|
|
|
|
(map (job: job.extraHttpdConfig) jobs);
|
2006-12-18 19:20:03 +00:00
|
|
|
})
|
|
|
|
|
2008-01-04 10:36:14 +00:00
|
|
|
# Apache httpd (new style).
|
2008-02-04 10:52:58 +00:00
|
|
|
++ optional (config.services.httpd.enable && config.services.httpd.experimental)
|
2008-01-04 10:36:14 +00:00
|
|
|
(import ../upstart-jobs/apache-httpd {
|
|
|
|
inherit config pkgs;
|
|
|
|
})
|
|
|
|
|
2008-01-28 14:30:18 +00:00
|
|
|
# MySQL server
|
|
|
|
++ optional config.services.mysql.enable
|
|
|
|
(import ../upstart-jobs/mysql.nix {
|
|
|
|
inherit config pkgs;
|
|
|
|
})
|
|
|
|
|
2007-12-03 04:48:31 +00:00
|
|
|
# Postgres SQL server
|
|
|
|
++ optional config.services.postgresql.enable
|
|
|
|
(import ../upstart-jobs/postgresql.nix {
|
|
|
|
inherit config pkgs;
|
|
|
|
})
|
|
|
|
|
2008-02-04 13:40:01 +00:00
|
|
|
# EJabberd service
|
|
|
|
++ optional config.services.ejabberd.enable
|
|
|
|
(import ../upstart-jobs/ejabberd.nix {
|
|
|
|
inherit config pkgs;
|
|
|
|
})
|
|
|
|
|
2008-03-03 19:28:10 +00:00
|
|
|
# OpenFire XMPP server
|
|
|
|
++ optional config.services.openfire.enable
|
|
|
|
(import ../upstart-jobs/openfire.nix {
|
|
|
|
inherit config pkgs;
|
|
|
|
})
|
|
|
|
|
2008-01-28 15:16:14 +00:00
|
|
|
# JBoss service
|
|
|
|
++ optional config.services.jboss.enable
|
|
|
|
(import ../upstart-jobs/jboss.nix {
|
|
|
|
inherit config pkgs;
|
|
|
|
})
|
|
|
|
|
2008-01-30 11:00:00 +00:00
|
|
|
# Apache Tomcat service
|
|
|
|
++ optional config.services.tomcat.enable
|
|
|
|
(import ../upstart-jobs/tomcat.nix {
|
|
|
|
inherit config pkgs;
|
|
|
|
})
|
|
|
|
|
2007-05-28 15:39:25 +00:00
|
|
|
# Samba service.
|
2007-11-09 18:49:45 +00:00
|
|
|
++ optional config.services.samba.enable
|
2007-05-28 15:39:25 +00:00
|
|
|
(import ../upstart-jobs/samba.nix {
|
|
|
|
inherit pkgs;
|
2007-06-10 20:13:12 +00:00
|
|
|
inherit (pkgs) glibc samba;
|
2007-05-28 15:39:25 +00:00
|
|
|
})
|
|
|
|
|
2007-04-02 17:31:58 +00:00
|
|
|
# CUPS (printing) daemon.
|
2007-11-09 18:49:45 +00:00
|
|
|
++ optional config.services.printing.enable
|
2007-04-02 17:31:58 +00:00
|
|
|
(import ../upstart-jobs/cupsd.nix {
|
2009-02-22 16:07:05 +00:00
|
|
|
inherit config pkgs modprobe;
|
2007-04-02 17:31:58 +00:00
|
|
|
})
|
|
|
|
|
2008-02-07 12:41:18 +00:00
|
|
|
# VSFTPd server
|
|
|
|
++ optional config.services.vsftpd.enable
|
|
|
|
(import ../upstart-jobs/vsftpd.nix {
|
|
|
|
inherit (pkgs) vsftpd;
|
2008-08-04 09:36:11 +00:00
|
|
|
inherit (config.services.vsftpd) anonymousUser
|
|
|
|
writeEnable anonymousUploadEnable anonymousMkdirEnable;
|
2008-02-07 12:41:18 +00:00
|
|
|
})
|
|
|
|
|
2007-11-05 08:54:30 +00:00
|
|
|
# X Font Server
|
2007-11-09 18:49:45 +00:00
|
|
|
++ optional config.services.xfs.enable
|
2008-01-04 10:54:33 +00:00
|
|
|
(import ../upstart-jobs/xfs.nix {
|
|
|
|
inherit config pkgs;
|
|
|
|
})
|
2007-11-05 08:54:30 +00:00
|
|
|
|
2007-11-09 18:49:45 +00:00
|
|
|
++ optional config.services.ircdHybrid.enable
|
2007-08-08 20:42:25 +00:00
|
|
|
(import ../upstart-jobs/ircd-hybrid.nix {
|
|
|
|
inherit config pkgs;
|
|
|
|
})
|
|
|
|
|
2008-06-30 15:13:02 +00:00
|
|
|
# Postfix mail server.
|
|
|
|
++ optional config.services.postfix.enable
|
|
|
|
(import ../upstart-jobs/postfix.nix {
|
|
|
|
inherit config pkgs;
|
|
|
|
})
|
2008-06-06 09:13:16 +00:00
|
|
|
|
2008-06-30 21:12:02 +00:00
|
|
|
# Dovecot POP3/IMAP server.
|
|
|
|
++ optional config.services.dovecot.enable
|
|
|
|
(import ../upstart-jobs/dovecot.nix {
|
|
|
|
inherit config pkgs;
|
|
|
|
})
|
|
|
|
|
2008-07-01 12:15:56 +00:00
|
|
|
# ISC BIND domain name server.
|
|
|
|
++ optional config.services.bind.enable
|
|
|
|
(import ../upstart-jobs/bind.nix {
|
|
|
|
inherit config pkgs;
|
|
|
|
})
|
|
|
|
|
2006-12-11 15:32:10 +00:00
|
|
|
# Handles the reboot/halt events.
|
|
|
|
++ (map
|
|
|
|
(event: makeJob (import ../upstart-jobs/halt.nix {
|
|
|
|
inherit (pkgs) bash utillinux;
|
|
|
|
inherit event;
|
|
|
|
}))
|
|
|
|
["reboot" "halt" "system-halt" "power-off"]
|
|
|
|
)
|
|
|
|
|
|
|
|
# The terminals on ttyX.
|
|
|
|
++ (map
|
|
|
|
(ttyNumber: makeJob (import ../upstart-jobs/mingetty.nix {
|
2007-01-08 22:41:41 +00:00
|
|
|
inherit (pkgs) mingetty;
|
|
|
|
inherit ttyNumber;
|
|
|
|
loginProgram = "${pkgs.pam_login}/bin/login";
|
2006-12-11 15:32:10 +00:00
|
|
|
}))
|
2007-11-09 18:49:45 +00:00
|
|
|
(config.services.mingetty.ttys)
|
2006-12-11 15:32:10 +00:00
|
|
|
)
|
|
|
|
|
2007-01-08 22:41:41 +00:00
|
|
|
# Transparent TTY backgrounds.
|
2008-06-10 16:10:23 +00:00
|
|
|
++ optional (config.services.ttyBackgrounds.enable && kernelPackages.splashutils != null)
|
2007-01-08 22:41:41 +00:00
|
|
|
(import ../upstart-jobs/tty-backgrounds.nix {
|
2008-05-22 11:59:46 +00:00
|
|
|
inherit (pkgs) stdenv;
|
|
|
|
inherit (kernelPackages) splashutils;
|
2007-01-08 22:41:41 +00:00
|
|
|
|
|
|
|
backgrounds =
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
specificThemes =
|
2007-11-09 18:49:45 +00:00
|
|
|
config.services.ttyBackgrounds.defaultSpecificThemes
|
|
|
|
++ config.services.ttyBackgrounds.specificThemes;
|
2007-01-08 22:41:41 +00:00
|
|
|
|
|
|
|
overridenTTYs = map (x: x.tty) specificThemes;
|
|
|
|
|
|
|
|
# Use the default theme for all the mingetty ttys and for the
|
|
|
|
# syslog tty, except those for which a specific theme is
|
|
|
|
# specified.
|
|
|
|
defaultTTYs =
|
2008-02-11 11:51:51 +00:00
|
|
|
pkgs.lib.filter (x: !(pkgs.lib.elem x overridenTTYs)) requiredTTYs;
|
2007-01-08 22:41:41 +00:00
|
|
|
|
|
|
|
in
|
|
|
|
(map (ttyNumber: {
|
|
|
|
tty = ttyNumber;
|
2007-11-09 18:49:45 +00:00
|
|
|
theme = config.services.ttyBackgrounds.defaultTheme;
|
2007-01-08 22:41:41 +00:00
|
|
|
}) defaultTTYs)
|
|
|
|
++ specificThemes;
|
|
|
|
|
|
|
|
})
|
|
|
|
|
2006-12-18 17:41:46 +00:00
|
|
|
# User-defined events.
|
2009-01-02 16:06:41 +00:00
|
|
|
++ (map makeJob (config.services.extraJobs));
|
2007-11-23 10:56:12 +00:00
|
|
|
|
2008-11-18 18:00:09 +00:00
|
|
|
|
|
|
|
command = import ../upstart-jobs/gather.nix {
|
|
|
|
inherit (pkgs) runCommand;
|
|
|
|
inherit jobs;
|
|
|
|
};
|
2009-01-02 16:06:41 +00:00
|
|
|
|
2008-11-18 18:00:09 +00:00
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
require = [
|
|
|
|
options
|
2009-01-02 16:06:41 +00:00
|
|
|
(import ./lib/default.nix)
|
2008-11-18 18:00:09 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
environment = {
|
|
|
|
etc = [{ # The Upstart events defined above.
|
|
|
|
source = command + "/etc/event.d";
|
|
|
|
target = "event.d";
|
|
|
|
}]
|
|
|
|
++ pkgs.lib.concatLists (map (job: job.extraEtc) jobs);
|
|
|
|
|
|
|
|
extraPackages =
|
|
|
|
pkgs.lib.concatLists (map (job: job.extraPath) jobs);
|
|
|
|
};
|
|
|
|
|
|
|
|
users = {
|
|
|
|
extraUsers =
|
|
|
|
pkgs.lib.concatLists (map (job: job.users) jobs);
|
|
|
|
|
|
|
|
extraGroups =
|
|
|
|
pkgs.lib.concatLists (map (job: job.groups) jobs);
|
|
|
|
};
|
|
|
|
|
2008-12-07 12:27:46 +00:00
|
|
|
services = {
|
2009-01-02 16:06:41 +00:00
|
|
|
extraJobs = [
|
|
|
|
# For the built-in logd job.
|
|
|
|
{ jobDrv = pkgs.upstart; }
|
|
|
|
];
|
2008-12-07 12:27:46 +00:00
|
|
|
};
|
|
|
|
|
2008-11-18 18:00:09 +00:00
|
|
|
tests = {
|
|
|
|
# see test/test-upstart-job.sh
|
|
|
|
upstartJobs = { recurseForDerivations = true; } //
|
|
|
|
builtins.listToAttrs (map (job:
|
|
|
|
{ name = if job ? jobName then job.jobName else job.name; value = job; }
|
|
|
|
) jobs);
|
|
|
|
};
|
2009-01-02 16:07:21 +00:00
|
|
|
}
|