diff --git a/nixos/modules/misc/locate.nix b/nixos/modules/misc/locate.nix index 1affb234e418..f12ca95d6ea0 100644 --- a/nixos/modules/misc/locate.nix +++ b/nixos/modules/misc/locate.nix @@ -1,6 +1,7 @@ { config, lib, + utils, pkgs, ... }: @@ -59,7 +60,7 @@ in }; output = lib.mkOption { - type = lib.types.path; + type = lib.types.externalPath; default = "/var/cache/locatedb"; description = '' The database file to build. @@ -249,27 +250,35 @@ in systemd.services.update-locatedb = { description = "Update Locate Database"; - # mlocate's updatedb takes flags via a configuration file or - # on the command line, but not by environment variable. - script = - let - toFlags = - x: lib.optional (cfg.${x} != [ ]) "--${lib.toLower x} '${lib.concatStringsSep " " cfg.${x}}'"; - args = lib.concatLists ( - map toFlags [ + serviceConfig = { + # mlocate's updatedb takes flags via a configuration file or + # on the command line, but not by environment variable. + ExecStart = + let + toFlags = + x: + lib.optionals (cfg.${x} != [ ]) [ + "--${lib.toLower x}" + (lib.concatStringsSep " " cfg.${x}) + ]; + args = lib.concatMap toFlags [ "pruneFS" "pruneNames" "prunePaths" + ]; + in + utils.escapeSystemdExecArgs ( + [ + (lib.getExe' cfg.package "updatedb") + "--output" + cfg.output + "--prune-bind-mounts" + (lib.boolToYesNo cfg.pruneBindMounts) ] + ++ args + ++ cfg.extraFlags ); - in - '' - exec ${cfg.package}/bin/updatedb \ - --output ${toString cfg.output} ${lib.concatStringsSep " " args} \ - --prune-bind-mounts ${lib.boolToYesNo cfg.pruneBindMounts} \ - ${lib.concatStringsSep " " cfg.extraFlags} - ''; - serviceConfig = { + CapabilityBoundingSet = "CAP_DAC_READ_SEARCH CAP_CHOWN"; Nice = 19; IOSchedulingClass = "idle";