From 4934f52bb7796bbe902b03fe68857b5e67e0d260 Mon Sep 17 00:00:00 2001 From: Mateusz Kowalczyk Date: Mon, 16 Jun 2014 08:03:29 +0200 Subject: [PATCH] locate service: allow customisation Fixes #2961 --- nixos/modules/misc/locate.nix | 39 ++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/nixos/modules/misc/locate.nix b/nixos/modules/misc/locate.nix index 45da0df7967c..7de63c606492 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 updatedb. + ''; + }; + + 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 + su. + ''; + }; + }; }; @@ -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";