diff options
author | Rickard Nilsson <rickynils@gmail.com> | 2014-10-01 17:22:21 +0200 |
---|---|---|
committer | Rickard Nilsson <rickynils@gmail.com> | 2014-10-01 17:33:38 +0200 |
commit | 57721a2888506d49a6fd5ac4bf1200f5a75dd138 (patch) | |
tree | 3a7b17350c596c32e9de095abd7e0b5db06be7aa /nixos/modules/services/scheduling/cron.nix | |
parent | 0b23b5b141ec4262952ba6fb428cb5b6dc56e2a1 (diff) | |
download | nixlib-57721a2888506d49a6fd5ac4bf1200f5a75dd138.tar nixlib-57721a2888506d49a6fd5ac4bf1200f5a75dd138.tar.gz nixlib-57721a2888506d49a6fd5ac4bf1200f5a75dd138.tar.bz2 nixlib-57721a2888506d49a6fd5ac4bf1200f5a75dd138.tar.lz nixlib-57721a2888506d49a6fd5ac4bf1200f5a75dd138.tar.xz nixlib-57721a2888506d49a6fd5ac4bf1200f5a75dd138.tar.zst nixlib-57721a2888506d49a6fd5ac4bf1200f5a75dd138.zip |
nixos: Add option services.cron.cronFiles
This allows you to configure extra files that should be appended to your crontab. Implemented by writing to /etc/crontab when the cron service starts. Would be nicer to use a cron that supports /etc/cron.d but that would require us to patch vixie-cron.
Diffstat (limited to 'nixos/modules/services/scheduling/cron.nix')
-rw-r--r-- | nixos/modules/services/scheduling/cron.nix | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/nixos/modules/services/scheduling/cron.nix b/nixos/modules/services/scheduling/cron.nix index 9ce0bcbec7eb..ded3010ec5ae 100644 --- a/nixos/modules/services/scheduling/cron.nix +++ b/nixos/modules/services/scheduling/cron.nix @@ -25,6 +25,10 @@ let sendmailPath = "/var/setuid-wrappers/sendmail"; }; + allFiles = map (f: "\"${f}\"") ( + [ "${systemCronJobsFile}" ] ++ config.services.cron.cronFiles + ); + in { @@ -71,6 +75,15 @@ in ''; }; + cronFiles = mkOption { + type = types.listOf types.path; + default = []; + description = '' + A list of extra crontab files that will be read and appended to the main + crontab file when the cron service starts. + ''; + }; + }; }; @@ -78,14 +91,7 @@ in ###### implementation - config = mkIf config.services.cron.enable { - - environment.etc = singleton - # The system-wide crontab. - { source = systemCronJobsFile; - target = "crontab"; - mode = "0600"; # Cron requires this. - }; + config = mkIf (config.services.cron.enable && allFiles != []) { security.setuidPrograms = [ "crontab" ]; @@ -100,6 +106,10 @@ in preStart = '' + rm -f /etc/crontab + cat ${toString allFiles} > /etc/crontab + chmod 0600 /etc/crontab + mkdir -m 710 -p /var/cron # By default, allow all users to create a crontab. This |