Evaluation of package differs depending on relative/absolute path

Hello all,

I have a situation where two seeming similar commands get different results:

$ cd ~/mydir
$ nix eval --raw ".mypackage"
/nix/store/cfr7lna3k4slvy3vk1z44b75jn33yrgj-mypackage-0.1.0

vs

$ nix eval --raw "path:///home/chris/mydir#mypackage"
/nix/store/mi7lmg4n45jnyi8ik422ynsk5srgyzwc-mypackage-0.1.0

This seems to be something to do with nix recognizing the directory as a git repo, in the first example - for example, I get this if working from within the directory, but not when dealing with the absolute path:

cd ~/mydir
nix path-info ".#mypackage" -vv                                                                                                                                                                
evaluating derivation 'git+file:///home/chris/mydir#mypackage'...
using revision 46b870de8add9099f39565de09f079dd0e56018d of repo '/home/chris/mydir'

I don’t understand, though, why these two would produce different hashes, and (if I have the straight choice between one versus the other) which one would be better to use.

Any help appreciated.

Chris

Yes.

The path: flake is copying the .git dir and all gitignored files, untracked files, etc - whatever’s in the directory - into the store as well.

1 Like

OK, thank you. So as regards the question which is better - under all circumstances I can readily think of it, it’s better not to use an absolute path via path.

That’s how I see it as well.