* Periodically update the locate database from cron when

config.services.locate.enable is set.

svn path=/nixos/trunk/; revision=10448
This commit is contained in:
Eelco Dolstra 2008-02-01 12:35:51 +00:00
parent 9f62e1a6a5
commit 0d50031a0a
3 changed files with 39 additions and 2 deletions

View file

@ -8,6 +8,7 @@ export FONTCONFIG_FILE=/etc/fonts/fonts.conf
export LANG=@defaultLocale@
export EDITOR=nano
export INFOPATH=/var/run/current-system/sw/info:/var/run/current-system/sw/share/info
export LOCATE_PATH=/var/cache/locatedb
# A nice prompt.

View file

@ -546,6 +546,29 @@
};
locate = {
enable = mkOption {
default = false;
example = true;
description = ''
If enabled, NixOS will periodically update the database of
files used by the <command>locate</command> 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 = {
enable = mkOption {

View file

@ -2,11 +2,24 @@
let
systemCronJobs = config.services.cron.systemCronJobs;
# !!! 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;
systemCronJobsFile = pkgs.writeText "system-crontab" ''
SHELL=${pkgs.bash}/bin/sh
PATH=${pkgs.coreutils}/bin
PATH=${pkgs.coreutils}/bin:${pkgs.findutils}/bin:${pkgs.gnused}/bin:${pkgs.su}/bin
MAILTO=
${pkgs.lib.concatStrings (map (job: job + "\n") systemCronJobs)}
'';