Use generated upstart-job's tags for cron.

svn path=/nixos/branches/fix-style/; revision=13593
This commit is contained in:
Nicolas Pierron 2008-12-07 12:27:46 +00:00
parent 2f0e8e370a
commit b47e6675b8
2 changed files with 43 additions and 3 deletions

View File

@ -34,6 +34,8 @@ in
###### implementation
let
inherit (config.services) jobsTags;
# Put all the system cronjobs together.
systemCronJobs =
config.services.cron.systemCronJobs;
@ -79,8 +81,8 @@ in
job = ''
description "Cron daemon"
start on startup
stop on shutdown
start on ${jobsTags.system.start}
stop on ${jobsTags.system.stop}
# Needed to interpret times in the local timezone.
env TZ=${config.time.timeZone}

View File

@ -2,7 +2,19 @@
###### interface
let
inherit (pkgs.lib) mkOption;
inherit (pkgs.lib) mkOption mapAttrs getAttr fold
mergeListOption mergeTypedOption mergeAttrsWithFunc;
mergeTags = mergeTypedOption "jobs tag" (x: true)
(fold (mergeAttrsWithFunc (a: b:
if builtins.lessThan a.priority b.priority then b else a
)) { priority = 100; });
applyTags = mapAttrs (attrName: value:
let name = getAttr ["name"] attrName value; in {
start = getAttr ["start"] (name + "/started") value;
stop = getAttr ["stop"] (name + "/stop") value;
});
options = {
services = {
@ -24,6 +36,22 @@ let
Additional Upstart jobs.
";
};
# this attribute must be computed before extraJobs.
jobsTags = mkOption {
default = {};
example = {
newtworkInterface = {
name = "gw6c";
priority = 5;
};
};
description = "
Allow jobs to overload jobs tags used by upstart jobs.
";
merge = mergeTags;
apply = applyTags;
};
};
tests = {
@ -480,6 +508,16 @@ in
pkgs.lib.concatLists (map (job: job.groups) jobs);
};
services = {
jobsTags = {
system = {
priority = 0;
start = "startup";
stop = "shutdown";
};
};
};
tests = {
# see test/test-upstart-job.sh
upstartJobs = { recurseForDerivations = true; } //