Closed benpye closed 3 months ago
I just hit this today.
# test.nix
with import <nixpkgs> {};
fetchFromGitHub {
owner = "NixOS";
repo = "nix";
rev = "master";
postFetch = ''
echo ${hello} > $out/foo
'';
hash = "sha256-cYnCDbIID6qZzpzu9ax6KfGiQ9JaQkc6GnXU7qx6B7k=";
}
$ nix build -f test.nix --print-out-paths
/nix/store/p30525s24kk8gcdgjpgjqra78fam66sx-source
$ nix eval -f test.nix outPath
"/nix/store/3k03r6dp1hpw1k8lw786ibdyc7bv07s1-source"
Same with the nix-build
/nix-instantiate
CLI.
This only happens if a derivation is added to the output (here hello
).
If I use a path instead (echo ${/some/file} > $out/foo
), I get a never-ending sequence of "hash mismatch" errors.
Minimal reproducer:
with import <nixpkgs> {};
let
mkDerivation = args:
derivation ({
system = "x86_64-linux";
builder = "${bash}/bin/bash";
PATH = "${coreutils}/bin";
args = ["-e" "-c" "eval \"$buildCommand\""];
} // args);
dep = mkDerivation {
name = "dep";
buildCommand = "echo foo > $out";
};
in
mkDerivation {
name = "test";
buildCommand = ''
mkdir -p $out
echo ${dep} > $out/dep
'';
outputHashMode = "recursive";
outputHashAlgo = "sha256";
outputHash = "sha256-rGi3RZBPE6sy5Np2EFQKKPmiH9foV25h+f0RUwezLng=";
}
Using builtins.trace
to print the outPath
agrees with nix eval
, while the actual build output is under the path printed by nix build
.
Weirdly enough I can't reproduce this in a Nix test, the two commands agree.
@thufschmitt any idea what's going on?
@ncfavier That output hash seems wrong. It may be colliding with a store path you already have, and thus the build short-circuits, but the eval just tells you what the outPath should be. Run the commands with an empty store, --store
, or otherwise invalidate the hash to check.
That's the hash Nix gives me after I try to build with an empty hash. Obviously it depends on stuff in nixpkgs so it might have changed now. Building in an empty store doesn't change anything.
Seems like this is a duplicate of https://github.com/NixOS/nix/issues/6660
Fixed in current Nix, e.g. the reproducer above gives
error: illegal path references in fixed-output derivation '/nix/store/h46iklv790mwzrr4kivhrdbf8glql0l6-test.drv'
This issue has been mentioned on NixOS Discourse. There might be relevant details there:
https://discourse.nixos.org/t/2024-06-12-nix-team-meeting-minutes-152/46958/1
Describe the bug
With #5854 being resolved I attempt to convert my nix-fpga-tools to a fixed output derivation again. Unfortunately when making
xilinx-ise-unwrapped
a fixed output derivation the store path produced, and the store path expected do not match.Steps To Reproduce
Note: This will require Nix 2.11.0 or later as without the fix for #5854 this would take an unreasonably long amount of time.
xilinx-ise-unwrapped
to be fixed output by adding the following tounwrapped.nix
:nix shell --verbose .#xilinx-ise
and observe it failing to buildxilinx-jtag-fw
as it attempts to reference a non existent store path.Expected behavior
The build of
xilinx-ise
succeeds as the only change from the working build is to makexilinx-ise-unwrapped
fixed output.nix-env --version
outputAdditional context
After building
xilinx-ise-unwrapped
derivation as fixed output the store path/nix/store/ajj7pswlap0jxql87a7dfdfss7378vra-xilinx-ise-unwrapped-14.7
is present.nix show-derivation
fails with:nix-store -qd
succeeds showing:Getting the derivation for the
.drv
gives a different expected out path, and this is the path that dependent derivations attempt to use: