2014-04-14 14:26:48 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
2013-08-14 00:58:55 +00:00
|
|
|
|
2014-04-14 14:26:48 +00:00
|
|
|
with lib;
|
2008-11-09 16:44:53 +00:00
|
|
|
|
|
|
|
let
|
2013-08-14 00:58:55 +00:00
|
|
|
|
|
|
|
locatedb = "/var/cache/locatedb";
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
###### interface
|
2008-11-09 16:44:53 +00:00
|
|
|
|
|
|
|
options = {
|
|
|
|
|
2013-08-14 00:58:55 +00:00
|
|
|
services.locate = {
|
|
|
|
|
|
|
|
enable = mkOption {
|
2013-10-30 16:37:45 +00:00
|
|
|
type = types.bool;
|
2013-08-14 00:58:55 +00:00
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
If enabled, NixOS will periodically update the database of
|
|
|
|
files used by the <command>locate</command> command.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
period = mkOption {
|
2013-10-30 16:37:45 +00:00
|
|
|
type = types.str;
|
2013-08-14 00:58:55 +00:00
|
|
|
default = "15 02 * * *";
|
|
|
|
description = ''
|
|
|
|
This option defines (in the format used by cron) when the
|
|
|
|
locate database is updated.
|
2013-10-30 16:37:45 +00:00
|
|
|
The default is to update at 02:15 at night every day.
|
2013-08-14 00:58:55 +00:00
|
|
|
'';
|
2008-11-09 16:44:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
};
|
2013-08-14 00:58:55 +00:00
|
|
|
|
2008-11-09 16:44:53 +00:00
|
|
|
};
|
|
|
|
|
2013-08-14 00:58:55 +00:00
|
|
|
###### implementation
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2013-08-14 00:58:55 +00:00
|
|
|
config = {
|
|
|
|
|
|
|
|
systemd.services.update-locatedb =
|
|
|
|
{ description = "Update Locate Database";
|
|
|
|
path = [ pkgs.su ];
|
|
|
|
script =
|
|
|
|
''
|
|
|
|
mkdir -m 0755 -p $(dirname ${locatedb})
|
2013-08-14 01:07:36 +00:00
|
|
|
exec updatedb --localuser=nobody --output=${locatedb} --prunepaths='/tmp /var/tmp /media /run'
|
2013-08-14 00:58:55 +00: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 00:58:55 +00:00
|
|
|
|
2008-11-09 16:44:53 +00:00
|
|
|
}
|