Fixing “Illegal path references in fixed-output derivation” in Nix
The other day I was working with fixed-output derivations. After copying several files to $out
, I was facing a “Illegal path references in fixed-output derivation error”. The only helpful reference on the internet I could find was the Nix source code on GitHub.
It took me a while to figure out what’s going on. You get this error when your fixed-output derivation places something in $out
which contains a Nix store path! This can for example be a script with a (patched) shebang that (accidentally) landed there.
What happened in my case
I was packaging Limine and the ./bootstrap
script performs several git clone
invocations. Each git clone
invocation creates .<repository>/git/hooks
with a few example hooks. Each hook is a shell script starting with a shebang.. and Git automatically puts the binaries it finds in its PATH into the shebang, which on my NixOS system were all coming from the Nix store. That was a fun thing to debug!
The solution in that specific case is to remove all **/.git/hooks
directories in that fixed-output derivation. 😂
0 Comments