Merge pull request #2963 from Fuuzetsu/locate

locate service: allow customisation

lethalman e497265b 1ecae5c2

Changed files
+31 -8
nixos
modules
misc
+31 -8
nixos/modules/misc/locate.nix
···
with lib;
let
-
-
locatedb = "/var/cache/locatedb";
-
-
in
-
-
{
+
cfg = config.services.locate;
+
in {
###### interface
···
'';
};
+
extraFlags = mkOption {
+
type = types.listOf types.str;
+
default = [ ];
+
description = ''
+
Extra flags to append to <command>updatedb</command>.
+
'';
+
};
+
+
output = mkOption {
+
type = types.path;
+
default = /var/cache/locatedb;
+
description = ''
+
The database file to build.
+
'';
+
};
+
+
localuser = mkOption {
+
type = types.str;
+
default = "nobody";
+
description = ''
+
The user to search non-network directories as, using
+
<command>su</command>.
+
'';
+
};
+
};
};
···
path = [ pkgs.su ];
script =
''
-
mkdir -m 0755 -p $(dirname ${locatedb})
-
exec updatedb --localuser=nobody --output=${locatedb} --prunepaths='/tmp /var/tmp /media /run'
+
mkdir -m 0755 -p $(dirname ${toString cfg.output})
+
exec updatedb \
+
--localuser=${cfg.localuser} \
+
--output=${toString cfg.output} ${concatStringsSep " " cfg.extraFlags}
'';
serviceConfig.Nice = 19;
serviceConfig.IOSchedulingClass = "idle";