diff --git a/system/options.nix b/system/options.nix index 47f6a162140d..2d670e972008 100644 --- a/system/options.nix +++ b/system/options.nix @@ -644,28 +644,6 @@ in }; }; - locate = { - - enable = mkOption { - default = false; - example = true; - description = '' - If enabled, NixOS will periodically update the database of - files used by the locate command. - ''; - }; - - period = mkOption { - default = "15 02 * * *"; - description = '' - This option defines (in the format used by cron) when the - locate database is updated. - The default is to update at 02:15 (at night) every day. - ''; - }; - - }; - ttyBackgrounds = { @@ -3050,5 +3028,6 @@ root ALL=(ALL) SETENV: ALL # services (import ../upstart-jobs/cron.nix) + (import ../upstart-jobs/cron/locate.nix) ]; } diff --git a/upstart-jobs/cron.nix b/upstart-jobs/cron.nix index 943c35f51d92..4220de6d647d 100644 --- a/upstart-jobs/cron.nix +++ b/upstart-jobs/cron.nix @@ -34,20 +34,9 @@ in ###### implementation let - # !!! This should be defined somewhere else. - locatedb = "/var/cache/locatedb"; - - updatedbCmd = - "${config.services.locate.period} root " + - "mkdir -m 0755 -p $(dirname ${locatedb}) && " + - "nice -n 19 ${pkgs.utillinux}/bin/ionice -c 3 " + - "updatedb --localuser=nobody --output=${locatedb} > /var/log/updatedb 2>&1"; - - # Put all the system cronjobs together. systemCronJobs = - config.services.cron.systemCronJobs ++ - pkgs.lib.optional config.services.locate.enable updatedbCmd; + config.services.cron.systemCronJobs; systemCronJobsFile = pkgs.writeText "system-crontab" '' SHELL=${pkgs.bash}/bin/sh diff --git a/upstart-jobs/cron/locate.nix b/upstart-jobs/cron/locate.nix new file mode 100644 index 000000000000..2b26a10e91e6 --- /dev/null +++ b/upstart-jobs/cron/locate.nix @@ -0,0 +1,60 @@ +{pkgs, config}: + +###### interface +let + inherit (pkgs.lib) mkOption; + + options = { + services = { + locate = { + + enable = mkOption { + default = false; + example = true; + description = '' + If enabled, NixOS will periodically update the database of + files used by the locate command. + ''; + }; + + period = mkOption { + default = "15 02 * * *"; + description = '' + This option defines (in the format used by cron) when the + locate database is updated. + The default is to update at 02:15 (at night) every day. + ''; + }; + + }; + + }; + }; +in + +###### implementation +let + locatedb = "/var/cache/locatedb"; + + updatedbCmd = + "${config.services.locate.period} root " + + "mkdir -m 0755 -p $(dirname ${locatedb}) && " + + "nice -n 19 ${pkgs.utillinux}/bin/ionice -c 3 " + + "updatedb --localuser=nobody --output=${locatedb} > /var/log/updatedb 2>&1"; +in + +{ + require = [ + (import ../../upstart-jobs/cron.nix) # config.services.cron + options + ]; + + services = { + cron = { + systemCronJobs = + pkgs.lib.optional + config.services.locate.enable + updatedbCmd; + }; + }; +}