2013-08-14 01:58:55 +01:00
|
|
|
{ config, pkgs, ... }:
|
|
|
|
|
|
|
|
with pkgs.lib;
|
2008-11-09 16:44:53 +00:00
|
|
|
|
|
|
|
let
|
2013-08-14 01:58:55 +01:00
|
|
|
|
|
|
|
locatedb = "/var/cache/locatedb";
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
###### interface
|
2008-11-09 16:44:53 +00:00
|
|
|
|
|
|
|
options = {
|
|
|
|
|
2013-08-14 01:58:55 +01:00
|
|
|
services.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.
|
|
|
|
'';
|
2008-11-09 16:44:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
};
|
2013-08-14 01:58:55 +01:00
|
|
|
|
2008-11-09 16:44:53 +00:00
|
|
|
};
|
|
|
|
|
2013-08-14 01:58:55 +01:00
|
|
|
###### implementation
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2013-08-14 01:58:55 +01:00
|
|
|
config = {
|
|
|
|
|
|
|
|
systemd.services.update-locatedb =
|
|
|
|
{ description = "Update Locate Database";
|
|
|
|
path = [ pkgs.su ];
|
|
|
|
script =
|
|
|
|
''
|
|
|
|
mkdir -m 0755 -p $(dirname ${locatedb})
|
2013-08-14 02:07:36 +01:00
|
|
|
exec updatedb --localuser=nobody --output=${locatedb} --prunepaths='/tmp /var/tmp /media /run'
|
2013-08-14 01:58:55 +01:00
|
|
|
'';
|
|
|
|
serviceConfig.Nice = 19;
|
|
|
|
serviceConfig.IOSchedulingClass = "idle";
|
|
|
|
};
|
|
|
|
|
|
|
|
services.cron.systemCronJobs = optional config.services.locate.enable
|
|
|
|
"${config.services.locate.period} root ${config.systemd.package}/bin/systemctl start update-locatedb.service";
|
2008-11-09 16:44:53 +00:00
|
|
|
|
|
|
|
};
|
2013-08-14 01:58:55 +01:00
|
|
|
|
2008-11-09 16:44:53 +00:00
|
|
|
}
|