diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2015-07-22 15:12:47 +0200 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2015-07-22 15:15:09 +0200 |
commit | e2b25f94347da698994a00120e79ed67f40b8f38 (patch) | |
tree | b6666e659f2ba051f5667aa92d38ad6b87c0f449 /nixos/modules/services/scheduling/cron.nix | |
parent | 201f9beddbf5786262bcff11482f0aa30914bb34 (diff) | |
download | nixlib-e2b25f94347da698994a00120e79ed67f40b8f38.tar nixlib-e2b25f94347da698994a00120e79ed67f40b8f38.tar.gz nixlib-e2b25f94347da698994a00120e79ed67f40b8f38.tar.bz2 nixlib-e2b25f94347da698994a00120e79ed67f40b8f38.tar.lz nixlib-e2b25f94347da698994a00120e79ed67f40b8f38.tar.xz nixlib-e2b25f94347da698994a00120e79ed67f40b8f38.tar.zst nixlib-e2b25f94347da698994a00120e79ed67f40b8f38.zip |
Use environment.etc to manage /etc/crontab
Otherwise, /etc/crontab won't be deleted when cron is disabled.
Diffstat (limited to 'nixos/modules/services/scheduling/cron.nix')
-rw-r--r-- | nixos/modules/services/scheduling/cron.nix | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/nixos/modules/services/scheduling/cron.nix b/nixos/modules/services/scheduling/cron.nix index c81d2bdefa70..a92e8b65d2ab 100644 --- a/nixos/modules/services/scheduling/cron.nix +++ b/nixos/modules/services/scheduling/cron.nix @@ -91,9 +91,7 @@ in config = mkMerge [ - { services.cron.enable = mkDefault (allFiles != []); - - } + { services.cron.enable = mkDefault (allFiles != []); } (mkIf (config.services.cron.enable && allFiles != []) { @@ -101,6 +99,17 @@ in environment.systemPackages = [ cronNixosPkg ]; + environment.etc.crontab = + { source = pkgs.runCommand "crontabs" { inherit allFiles; } + '' + touch $out + for i in $allFiles; do + cat "$i" >> $out + done + ''; + mode = "0600"; # Cron requires this. + }; + systemd.services.cron = { description = "Cron Daemon"; @@ -108,10 +117,6 @@ in preStart = '' - rm -f /etc/crontab - cat ${concatMapStrings (f: "\"${f}\" ") allFiles} > /etc/crontab - chmod 0600 /etc/crontab - mkdir -m 710 -p /var/cron # By default, allow all users to create a crontab. This |