···125125 warnings = optional (isMLocate && cfg.localuser != null) "mlocate does not support searching as user other than root"
126126 ++ optional (isFindutils && cfg.pruneNames != []) "findutils locate does not support pruning by directory component"
127127 ++ optional (isFindutils && cfg.pruneBindMounts) "findutils locate does not support skipping bind mounts";
128128-128128+129129+ # directory creation needs to be separated from main service
130130+ # because ReadWritePaths fails when the directory doesn't already exist
131131+ systemd.tmpfiles.rules = [ "d ${dirOf cfg.output} 0755 root root -" ];
132132+129133 systemd.services.update-locatedb =
130134 { description = "Update Locate Database";
131135 path = mkIf (!isMLocate) [ pkgs.su ];
132136 script =
133137 ''
134134- mkdir -m 0755 -p ${dirOf cfg.output}
135138 exec ${cfg.locate}/bin/updatedb \
136139 ${optionalString (cfg.localuser != null && ! isMLocate) ''--localuser=${cfg.localuser}''} \
137140 --output=${toString cfg.output} ${concatStringsSep " " cfg.extraFlags}
···148151 serviceConfig.PrivateNetwork = "yes";
149152 serviceConfig.NoNewPrivileges = "yes";
150153 serviceConfig.ReadOnlyPaths = "/";
154154+ # Use dirOf cfg.output because mlocate creates temporary files next to
155155+ # the actual database. We could specify and create them as well,
156156+ # but that would make this quite brittle when they change something.
157157+ # NOTE: If /var/cache does not exist, this leads to the misleading error message:
158158+ # update-locatedb.service: Failed at step NAMESPACE spawning …/update-locatedb-start: No such file or directory
151159 serviceConfig.ReadWritePaths = dirOf cfg.output;
152160 };
153161