From 866987a60ed197add209b618daaf8cccb52ed4a7 Mon Sep 17 00:00:00 2001 From: Nicolas Pierron Date: Sun, 9 Nov 2008 16:44:43 +0000 Subject: [PATCH] cron.nix: Use the new option scheme. svn path=/nixos/trunk/; revision=13235 --- system/options.nix | 27 ++----------- system/system.nix | 1 - upstart-jobs/cron.nix | 86 ++++++++++++++++++++++++++++++++-------- upstart-jobs/default.nix | 5 --- 4 files changed, 73 insertions(+), 46 deletions(-) diff --git a/system/options.nix b/system/options.nix index d60a99d470a..47f6a162140 100644 --- a/system/options.nix +++ b/system/options.nix @@ -626,29 +626,6 @@ in }; - cron = { - - mailto = mkOption { - default = ""; - description = " The job output will be mailed to this email address. "; - }; - - systemCronJobs = mkOption { - default = []; - example = [ - "* * * * * test ls -l / > /tmp/cronout 2>&1" - "* * * * * eelco echo Hello World > /home/eelco/cronout" - ]; - description = '' - A list of Cron jobs to be appended to the system-wide - crontab. See the manual page for crontab for the expected - format. If you want to get the results mailed you must setuid - sendmail. See - ''; - }; - - }; - atd = { enable = mkOption { @@ -3067,7 +3044,11 @@ root ALL=(ALL) SETENV: ALL require = [ # newtworking (import ../upstart-jobs/dhclient.nix) + # hardware (import ../upstart-jobs/pcmcia.nix) + + # services + (import ../upstart-jobs/cron.nix) ]; } diff --git a/system/system.nix b/system/system.nix index d0d1946038a..eaa26cdea56 100644 --- a/system/system.nix +++ b/system/system.nix @@ -176,7 +176,6 @@ rec { pkgs.bzip2 pkgs.coreutils pkgs.cpio - pkgs.cron pkgs.curl pkgs.e2fsprogs pkgs.findutils diff --git a/upstart-jobs/cron.nix b/upstart-jobs/cron.nix index 209eb562fa9..943c35f51d9 100644 --- a/upstart-jobs/cron.nix +++ b/upstart-jobs/cron.nix @@ -1,7 +1,39 @@ {pkgs, config}: +###### interface let + inherit (pkgs.lib) mkOption; + options = { + services = { + cron = { + + mailto = mkOption { + default = ""; + description = " The job output will be mailed to this email address. "; + }; + + systemCronJobs = mkOption { + default = []; + example = [ + "* * * * * test ls -l / > /tmp/cronout 2>&1" + "* * * * * eelco echo Hello World > /home/eelco/cronout" + ]; + description = '' + A list of Cron jobs to be appended to the system-wide + crontab. See the manual page for crontab for the expected + format. If you want to get the results mailed you must setuid + sendmail. See + ''; + }; + + }; + }; + }; +in + +###### implementation +let # !!! This should be defined somewhere else. locatedb = "/var/cache/locatedb"; @@ -25,27 +57,47 @@ let ''; in - + { - name = "cron"; - - extraEtc = [ - # The system-wide crontab. - { source = systemCronJobsFile; - target = "crontab"; - mode = "0600"; # Cron requires this. - } + require = [ + # (import ../upstart-jobs/default.nix) # config.services.extraJobs + # (import ?) # config.time.timeZone + # (import ?) # config.environment.etc + # (import ?) # config.environment.extraPackages + # (import ?) # config.environment.cleanStart + options ]; - job = '' - description "Cron daemon" + environment = { + etc = [ + # The system-wide crontab. + { source = systemCronJobsFile; + target = "crontab"; + mode = "0600"; # Cron requires this. + } + ]; - start on startup - stop on shutdown + extraPackages = + pkgs.lib.optional + (!config.environment.cleanStart) + pkgs.cron; + }; - # Needed to interpret times in the local timezone. - env TZ=${config.time.timeZone} + services = { + extraJobs = [{ + name = "cron"; - respawn ${pkgs.cron}/sbin/cron -n - ''; + job = '' + description "Cron daemon" + + start on startup + stop on shutdown + + # Needed to interpret times in the local timezone. + env TZ=${config.time.timeZone} + + respawn ${pkgs.cron}/sbin/cron -n + ''; + }]; + }; } diff --git a/upstart-jobs/default.nix b/upstart-jobs/default.nix index e7cf35133c6..6bc7cff9ceb 100644 --- a/upstart-jobs/default.nix +++ b/upstart-jobs/default.nix @@ -140,11 +140,6 @@ let inherit config pkgs nix nixEnvVars; }) - # Cron daemon. - (import ../upstart-jobs/cron.nix { - inherit config pkgs; - }) - # Name service cache daemon. (import ../upstart-jobs/nscd.nix { inherit (pkgs) glibc;