I am stuck creating a package, where I did not expect to. The build fails with “path ‘X’ is not valid” and I don’t understand why.
patching script interpreter paths in /nix/store/zzdsz3533cl305aidl9h9s2a8hrhzfw6-gitversion
checking for references to /build/ in /nix/store/zzdsz3533cl305aidl9h9s2a8hrhzfw6-gitversion...
error: path '/nix/store/zzdsz3533cl305aidl9h9s2a8hrhzfw6-gitversion' is not valid
I have created a gist of the draft here
Certain files seam to offend the build, so I have removed them. Then again using
wrapProgram to set an environment variable, makes the build fail again. I tried to build with
-vvvv but this did not help me see the problem.
I am guessing it is offended by some reference, but I have no clue which or why.
Any ideas are welcome.
Edit: Found the source of “checking for references to /build/”, it is
and can be disabled with
noAuditTmpdir = true; but does not resolve the issue.
Those files contain the $out path. If I replace it, it works. It appears that files referencing $out are not allowed. Is this counting as a cyclic reference?
Not too sure anymore of what is allowed at the moment, but your derivation provides an output hash
outputHashAlgo = "sha256";
outputHash = "1111111111111111111111111111111111111111111111111111";
outputHashMode = "recursive";
it is therefore considered a “fixed output” derivation. This is specific to some derivations. typically to download sources from internet repositories. In that case, nix requires you to provide the hash of the final content to let you access the network.
I think these derivations are not allowed to have dependencies at the moment (it may change in the future).
That being said, the lines
are kind of a code smell. You are not supposed to know the output path name inside the derivation. You should use
Now, if you want to have references inside your package, you should split it in two. One part that downloads the sources from internet, that has fixed output. an a second part that uses these sources to build a “normal” derivation, without a fixed hash.
This pain is induced because you cannot possibly give in advance the content hash of a path that contains self-references, ans that hash hashes over itself.
Thank you very much for the input @layus
It is most certainly an additional restriction on fixed-output derivations.
I wanted to use
dotnet tool install as a fetcher, but it does not actually produce a fixed output. I will try a different approach.
I should have mentionned this earlier, since you are not likely to find this by yourself, but I somehow missed it.
Well, since this is a dotnet package, we have some supprt for them. Have a look in dotnet-packages.nix for how we handle nu-get and dotnet related software. I once packaged dafny, which was not following any kind of standard dortnet structure, and found the buildDotnetPackage quite tunable to my needs.
It is defined here if you ever need to have a look at it https://github.com/NixOS/nixpkgs/blob/766b78841f2342e325e0d801c01ab9d652150a67/pkgs/build-support/build-dotnet-package/default.nix
There’s an item here: https://github.com/NixOS/nixpkgs/issues/78054 for me to update the documentation. Just slammed right now with moving, which is taking up all of my free time.
I had this exact same issue in Error: path '/nix/store/…' is not valid. In my case, deleting a sqlite3 database from the path caused it to stop being invalid. I never did figure out why the sqlite3 database meant the path was invalid though.