Code change:
Using more-or-less the default configuration for (with ), the list of results is printed twice whenever running . For example: Steps to reproduce the behavior: the module like so: the job with some file name that exists on the system Matching files should each be printed once. The issue is fixed if I unset the environment variable. plocate deliberately reads from both and the hard coded default path, even if they are the same: The comment claims that this is also the behavior of mlocate, but I do not have an mlocate database installed and haven't wanted to change my running system to use mlocate. It looks like recently started being set in NixOS in . Please run and paste the result.
Sounds to me like an upstream issue. Can you write a mail to the upstream maintainer? ;a=blob;f=README;h=;hb=HEAD#l40
Sure, I have done so. I'll follow up when I get a response.
The plocate maintainer says they do not consider this to be a bug in plocate, and is intentional behavior. Rather than setting the environment variable, could we just make a wrapper script for that uses the NixOS-configured dbpath, if we don't want to re-build itself when the path is changed?
I would be personally fine to just drop support for a custom place for the db. If people really want to have it somewhere else they could symlink it. Then we don't need a wrapper or to worry about the env.
I can confirm the behaviour with .
Could we just take out the variable setting? It isn't needed for or , and just causes this annoying behaviour. If it's needed for , maybe the setting could be made conditional. It would be nice to get something done about it sooner rather than later. This issue has been open for 4 months now.
Please take a look at
I've reviewed the PR and it LGTM. Thanks for doing this! It will be great to have this fixed.

Related discussion:
text: { config, lib, pkgs, ... }: <del> with lib; </del> let cfg = config.services.locate; <del> isMLocate = hasPrefix "mlocate" cfg.package.name; isPLocate = hasPrefix "plocate" cfg.package.name; </del> <ins> isMLocate = lib.hasPrefix "mlocate" cfg.package.name; isPLocate = lib.hasPrefix "plocate" cfg.package.name; </ins> isMorPLocate = isMLocate || isPLocate; <del> isFindutils = hasPrefix "findutils" cfg.package.name; </del> <ins> isFindutils = lib.hasPrefix "findutils" cfg.package.name; </ins> in { imports = [ <del> (mkRenamedOptionModule [ "services" "locate" "period" ] [ "services" "locate" "interval" ]) (mkRenamedOptionModule [ "services" "locate" "locate" ] [ "services" "locate" "package" ]) (mkRemovedOptionModule [ "services" "locate" "includeStore" ] "Use services.locate.prunePaths") </del> <ins> (lib.mkRenamedOptionModule [ "services" "locate" "period" ] [ "services" "locate" "interval" ]) (lib.mkRenamedOptionModule [ "services" "locate" "locate" ] [ "services" "locate" "package" ]) (lib.mkRemovedOptionModule [ "services" "locate" "includeStore" ] "Use services.locate.prunePaths") </ins> ]; <del> options.services.locate = with types; { enable = mkOption { type = bool; </del> <ins> options.services.locate = { enable = lib.mkOption { type = lib.types.bool; </ins> default = false; description = '' If enabled, NixOS will periodically update the database of