From fc62de20436897f38866b5f287c348628fd182a7 Mon Sep 17 00:00:00 2001 From: milahu Date: Sun, 28 Mar 2021 17:20:18 +0200 Subject: locate.nix: write /etc/updatedb.conf --- nixos/modules/misc/locate.nix | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'nixos') 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 systemd.time 7. + + To disable automatic updates, set to "never" + and run updatedb 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" ]; -- cgit 1.4.1