Description
Describe the bug
Invoking nix build
against a string containing a store path causes sadness: it does not build anything and returns an error seemingly nothing to do with the actual problem.
Steps To Reproduce
Put this in a file:
let
Caddyfile-formatted = builtins.derivation { system = "x86_64-linux"; name = "test"; builder = "/bin/sh"; args = ["-c" "> $out" ]; };
in
"${Caddyfile-formatted}/Caddyfile"
nix build -f ./bug.nix
error:
… while evaluating the attribute ''
at «none»:0: (source not available)
error: string '/nix/store/nfb1lb8dd7wxn0g9cccq2a9zf8dk219a-test/Caddyfile' has context with the output 'out' from derivation '/nix/store/qvryn0lpyyizpqn55i9fdklb5l3d97b6-test.drv', but the string is not the right placeholder for this derivation
output. It should be '/nix/store/nfb1lb8dd7wxn0g9cccq2a9zf8dk219a-test'
Expected behavior
I expected the error message to be less bad, for example, what nix-build bug.nix
does:
error: expression does not evaluate to a derivation (or a set or list of those)
although I will note that that error is also terrible, but for different reasons: it doesn't do the thing you want. The case I had here is that I needed to nix eval
some string, and then build the derivation from it. I took the store path in the string and gave it to nix build
, but it couldn't identify the derivation file necessary to build it.
nix-env --version
output
nix-env (Nix) 2.18.1
Additional context
This occurred in practice while trying to get something out of a NixOS config under environment.etc.something.source
.
Priorities
Add 👍 to issues you find important.
Activity