summary refs log tree commit diff
path: root/nixos/modules/misc/locate.nix
diff options
context:
space:
mode:
authorMateusz Kowalczyk <fuuzetsu@fuuzetsu.co.uk>2014-06-16 08:03:29 +0200
committerMateusz Kowalczyk <fuuzetsu@fuuzetsu.co.uk>2014-06-24 12:54:16 +0200
commit4934f52bb7796bbe902b03fe68857b5e67e0d260 (patch)
tree21ce9755e295279e7cf9c6f9cbc0c41c6691cdf3 /nixos/modules/misc/locate.nix
parent9ff0b303ff4b954748920041b4385ecc7ce1b338 (diff)
downloadnixpkgs-4934f52bb7796bbe902b03fe68857b5e67e0d260.tar
nixpkgs-4934f52bb7796bbe902b03fe68857b5e67e0d260.tar.gz
nixpkgs-4934f52bb7796bbe902b03fe68857b5e67e0d260.tar.bz2
nixpkgs-4934f52bb7796bbe902b03fe68857b5e67e0d260.tar.lz
nixpkgs-4934f52bb7796bbe902b03fe68857b5e67e0d260.tar.xz
nixpkgs-4934f52bb7796bbe902b03fe68857b5e67e0d260.tar.zst
nixpkgs-4934f52bb7796bbe902b03fe68857b5e67e0d260.zip
locate service: allow customisation
Fixes #2961
Diffstat (limited to 'nixos/modules/misc/locate.nix')
-rw-r--r--nixos/modules/misc/locate.nix39
1 files changed, 31 insertions, 8 deletions
diff --git a/nixos/modules/misc/locate.nix b/nixos/modules/misc/locate.nix
index 45da0df7967..7de63c60649 100644
--- a/nixos/modules/misc/locate.nix
+++ b/nixos/modules/misc/locate.nix
@@ -3,12 +3,8 @@
 with lib;
 
 let
-
-  locatedb = "/var/cache/locatedb";
-
-in
-
-{
+  cfg = config.services.locate;
+in {
 
   ###### interface
 
@@ -35,6 +31,31 @@ in
         '';
       };
 
+      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>.
+        '';
+      };
+
     };
 
   };
@@ -48,8 +69,10 @@ in
         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";