Use environment.etc to manage /etc/crontab
Otherwise, /etc/crontab won't be deleted when cron is disabled.
This commit is contained in:
parent
201f9beddb
commit
e2b25f9434
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user