From b47e6675b838807a7a6cf63da08ce19ca21d8bcf Mon Sep 17 00:00:00 2001 From: Nicolas Pierron <nicolas.b.pierron@gmail.com> Date: Sun, 7 Dec 2008 12:27:46 +0000 Subject: [PATCH] Use generated upstart-job's tags for cron. svn path=/nixos/branches/fix-style/; revision=13593 --- upstart-jobs/cron.nix | 6 ++++-- upstart-jobs/default.nix | 40 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/upstart-jobs/cron.nix b/upstart-jobs/cron.nix index 2806ee92b96c..45a3295f7165 100644 --- a/upstart-jobs/cron.nix +++ b/upstart-jobs/cron.nix @@ -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} diff --git a/upstart-jobs/default.nix b/upstart-jobs/default.nix index fee24e3b5ec1..4b42d8a77389 100644 --- a/upstart-jobs/default.nix +++ b/upstart-jobs/default.nix @@ -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; } //