summary refs log tree commit diff
path: root/nixos/modules
diff options
context:
space:
mode:
authormilahu <milahu@gmail.com>2021-03-28 17:20:18 +0200
committermilahu <milahu@gmail.com>2021-03-29 13:15:30 +0200
commitfc62de20436897f38866b5f287c348628fd182a7 (patch)
tree27c0b560528a506ba6360b1ef607b08055192c67 /nixos/modules
parent6ac771d917baa4c8cc21c4fcd9814e36a3d7c616 (diff)
downloadnixpkgs-fc62de20436897f38866b5f287c348628fd182a7.tar
nixpkgs-fc62de20436897f38866b5f287c348628fd182a7.tar.gz
nixpkgs-fc62de20436897f38866b5f287c348628fd182a7.tar.bz2
nixpkgs-fc62de20436897f38866b5f287c348628fd182a7.tar.lz
nixpkgs-fc62de20436897f38866b5f287c348628fd182a7.tar.xz
nixpkgs-fc62de20436897f38866b5f287c348628fd182a7.tar.zst
nixpkgs-fc62de20436897f38866b5f287c348628fd182a7.zip
locate.nix: write /etc/updatedb.conf
Diffstat (limited to 'nixos/modules')
-rw-r--r--nixos/modules/misc/locate.nix17
1 files changed, 16 insertions, 1 deletions
diff --git a/nixos/modules/misc/locate.nix b/nixos/modules/misc/locate.nix
index 1d2bc8c7281..5d2f9a21bc5 100644
--- a/nixos/modules/misc/locate.nix
+++ b/nixos/modules/misc/locate.nix
@@ -43,6 +43,9 @@ in {
         The format is described in
         <citerefentry><refentrytitle>systemd.time</refentrytitle>
         <manvolnum>7</manvolnum></citerefentry>.
+
+        To disable automatic updates, set to <literal>"never"</literal>
+        and run <command>updatedb</command> manually.
       '';
     };
 
@@ -192,6 +195,18 @@ in {
       { LOCATE_PATH = cfg.output;
       };
 
+    environment.etc = {
+      # write /etc/updatedb.conf for manual calls to `updatedb`
+      "updatedb.conf" = {
+        text = ''
+          PRUNEFS="${lib.concatStringsSep " " cfg.pruneFS}"
+          PRUNENAMES="${lib.concatStringsSep " " cfg.pruneNames}"
+          PRUNEPATHS="${lib.concatStringsSep " " cfg.prunePaths}"
+          PRUNE_BIND_MOUNTSFR="${lib.boolToString cfg.pruneBindMounts}"
+        '';
+      };
+    };
+
     warnings = optional (isMLocate && cfg.localuser != null) "mlocate does not support the services.locate.localuser option; updatedb will run as root. (Silence with services.locate.localuser = null.)"
             ++ optional (isFindutils && cfg.pruneNames != []) "findutils locate does not support pruning by directory component"
             ++ optional (isFindutils && cfg.pruneBindMounts) "findutils locate does not support skipping bind mounts";
@@ -238,7 +253,7 @@ in {
         serviceConfig.ReadWritePaths = dirOf cfg.output;
       };
 
-    systemd.timers.update-locatedb =
+    systemd.timers.update-locatedb = mkIf (cfg.interval != "never")
       { description = "Update timer for locate database";
         partOf      = [ "update-locatedb.service" ];
         wantedBy    = [ "timers.target" ];