···
1
-
{ config, lib, pkgs, ... }:
1
+
{ config, options, lib, pkgs, ... }:
cfg = config.services.locate;
8
+
options.services.locate = {
13
+
If enabled, NixOS will periodically update the database of
14
+
files used by the <command>locate</command> command.
18
+
interval = mkOption {
23
+
Update the locate database at this interval. Updates by
24
+
default at 2:15 AM every day.
26
+
The format is described in
27
+
<citerefentry><refentrytitle>systemd.time</refentrytitle>
28
+
<manvolnum>7</manvolnum></citerefentry>.
32
+
# This is no longer supported, but we keep it to give a better warning below
33
+
period = mkOption { visible = false; };
19
-
If enabled, NixOS will periodically update the database of
20
-
files used by the <command>locate</command> command.
35
+
extraFlags = mkOption {
36
+
type = types.listOf types.str;
39
+
Extra flags to pass to <command>updatedb</command>.
26
-
default = "15 02 * * *";
28
-
This option defines (in the format used by cron) when the
29
-
locate database is updated.
30
-
The default is to update at 02:15 at night every day.
45
+
default = "/var/cache/locatedb";
47
+
The database file to build.
34
-
extraFlags = mkOption {
35
-
type = types.listOf types.str;
38
-
Extra flags to pass to <command>updatedb</command>.
44
-
default = "/var/cache/locatedb";
46
-
The database file to build.
50
-
localuser = mkOption {
54
-
The user to search non-network directories as, using
55
-
<command>su</command>.
59
-
includeStore = mkOption {
63
-
Whether to include <filename>/nix/store</filename> in the locate database.
51
+
localuser = mkOption {
55
+
The user to search non-network directories as, using
56
+
<command>su</command>.
60
+
includeStore = mkOption {
64
+
Whether to include <filename>/nix/store</filename> in the locate database.
71
-
###### implementation
70
+
warnings = let opt = options.services.locate.period; in optional opt.isDefined "The `period` definition in ${showFiles opt.files} has been removed; please replace it with `interval`, using the new systemd.time interval specifier.";
systemd.services.update-locatedb =
{ description = "Update Locate Database";
···
serviceConfig.IOSchedulingClass = "idle";
85
+
serviceConfig.PrivateTmp = "yes";
86
+
serviceConfig.PrivateNetwork = "yes";
87
+
serviceConfig.NoNewPrivileges = "yes";
88
+
serviceConfig.ReadOnlyDirectories = "/";
89
+
serviceConfig.ReadWriteDirectories = cfg.output;
89
-
services.cron.systemCronJobs = optional config.services.locate.enable
90
-
"${config.services.locate.period} root ${config.systemd.package}/bin/systemctl start update-locatedb.service";
92
+
systemd.timers.update-locatedb = mkIf cfg.enable
93
+
{ description = "Update timer for locate database";
94
+
partOf = [ "update-locatedb.service" ];
95
+
wantedBy = [ "timers.target" ];
96
+
timerConfig.OnCalendar = cfg.interval;