Description
Is your feature request related to a problem? Please describe.
I'll use a flake example, but this applies to anything that uses evaluation-time fetchers such as fetchTree.
When invoking a command like the following, nix-darwin
is specified twice.
$ nix run \
"/home/user/h/nix-darwin?dir=modules/examples/flake#darwinConfigurations.simple.config.system.build.vm"
--override-input nix-darwin /home/user/h/nix-darwin
--override-input nixpkgs git+file:///home/user/h/nixpkgs
warning: Git tree '/home/user/h/nix-darwin' is dirty
warning: Git tree '/home/user/h/nix-darwin' is dirty
warning: Git tree '/home/user/h/nixpkgs' is dirt
As you can see, nix-darwin
is processed twice.
Probably this could be worked around by avoiding dir
in this case, but in general it seems worthwhile to deduplicate source paths internally.
Describe the solution you'd like
Deduplicate source paths based on fingerprint (when a fingerprint exists), before constructing a new instance, before fetching it to the store. Use a weak pointer map so that the source paths can be released when no more true references are held.
Describe alternatives you've considered
Additional context
Installables should also be deduplicated, but this is a different problem. (#9724)
Priorities
Add 👍 to issues you find important.