mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-13 21:50:33 +03:00
Don't enable cron by default
The rationale for disabling this is: 1) systemd timers are better; 2) it gets rid of one usually unnecessary process, which makes containers more light-weight. Note that cron is still enabled if services.cron.systemCronJobs is non-empty, so this only matters if you have no declarative cron jobs but do have user cron jobs.
This commit is contained in:
parent
db22d387db
commit
201f9beddb
2 changed files with 40 additions and 28 deletions
|
@ -36,7 +36,7 @@
|
|||
|
||||
</para>
|
||||
|
||||
<para>Following new services were added since the last release:
|
||||
<para>The following new services were added since the last release:
|
||||
|
||||
<itemizedlist>
|
||||
<listitem><para><literal>brltty</literal></para></listitem>
|
||||
|
@ -50,6 +50,12 @@ following incompatible changes:
|
|||
|
||||
<itemizedlist>
|
||||
|
||||
<listitem><para><command>cron</command> is no longer enabled by
|
||||
default, unless you have a non-empty
|
||||
<option>services.cron.systemCronJobs</option>. To force
|
||||
<command>cron</command> to be enabled, set
|
||||
<option>services.cron.enable = true</option>.</para></listitem>
|
||||
|
||||
<listitem><para>Steam now doesn't need root rights to work. Instead of using
|
||||
<literal>*-steam-chrootenv</literal>, you should now just run <literal>steam</literal>.
|
||||
<literal>steamChrootEnv</literal> package was renamed to <literal>steam</literal>,
|
||||
|
|
|
@ -4,8 +4,6 @@ with lib;
|
|||
|
||||
let
|
||||
|
||||
inherit (config.services) jobsTags;
|
||||
|
||||
# Put all the system cronjobs together.
|
||||
systemCronJobsFile = pkgs.writeText "system-crontab"
|
||||
''
|
||||
|
@ -25,9 +23,9 @@ let
|
|||
sendmailPath = "/var/setuid-wrappers/sendmail";
|
||||
};
|
||||
|
||||
allFiles = map (f: "\"${f}\"") (
|
||||
[ "${systemCronJobsFile}" ] ++ config.services.cron.cronFiles
|
||||
);
|
||||
allFiles =
|
||||
optional (config.services.cron.systemCronJobs != []) systemCronJobsFile
|
||||
++ config.services.cron.cronFiles;
|
||||
|
||||
in
|
||||
|
||||
|
@ -91,7 +89,13 @@ in
|
|||
|
||||
###### implementation
|
||||
|
||||
config = mkIf (config.services.cron.enable && allFiles != []) {
|
||||
config = mkMerge [
|
||||
|
||||
{ services.cron.enable = mkDefault (allFiles != []);
|
||||
|
||||
}
|
||||
|
||||
(mkIf (config.services.cron.enable && allFiles != []) {
|
||||
|
||||
security.setuidPrograms = [ "crontab" ];
|
||||
|
||||
|
@ -105,7 +109,7 @@ in
|
|||
preStart =
|
||||
''
|
||||
rm -f /etc/crontab
|
||||
cat ${toString allFiles} > /etc/crontab
|
||||
cat ${concatMapStrings (f: "\"${f}\" ") allFiles} > /etc/crontab
|
||||
chmod 0600 /etc/crontab
|
||||
|
||||
mkdir -m 710 -p /var/cron
|
||||
|
@ -121,6 +125,8 @@ in
|
|||
serviceConfig.ExecStart = "${cronNixosPkg}/bin/cron -n";
|
||||
};
|
||||
|
||||
};
|
||||
})
|
||||
|
||||
];
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue