NixOS / nix

Nix, the purely functional package manager
https://nixos.org/
GNU Lesser General Public License v2.1
12.05k stars 1.47k forks source link

nix-build fails to look <paths> up in its arguments #11094

Open nbraud opened 1 month ago

nbraud commented 1 month ago

Describe the bug

Following a recent update, building my NixOS systems fails with the following:

$ nix-build --option nix-path nixos-config=${PWD}/sys/helium.nix:${PWD}:${PWD}/3rd-party -Q -o /tmp/nix-config.yMmX0C/out -A system '<nixpkgs/nixos>'
error: file 'nixpkgs/nixos' was not found in the Nix search path (add it using $NIX_PATH or -I)

nixpkgs is present in the nix path, under 3rd-party/.

Steps To Reproduce

Run nix-build --option nix-path nixos-config=...:nixpkgs=... -A system '<nixpkgs/nixos>'

Expected behavior

The system is built, as on previous versions.

nix-env --version output

nix-env (Nix) 2.18.4

Additional context

My script previously set the NIX_PATH environment variable, which was similarly broken, and I switched to setting --option nix-path after finding #10246; since setting nix-path in parameters does not work either, this is likely a distinct bug.

Using -I did not work either, nor did explicitely adding nixpkgs=.../3rd-party/nixpkgs to the path.

Hard-conding the path to nixpkgs/nixos in the call to nix-build gives a warning suggesting the path is not being parsed correctly anymore:

warning: Nix search path entry '/home/nicoo/dev/nix/config/sys/helium.nix:/home/nicoo/dev/nix/config:/home/nicoo/dev/nix/config/3rd-party:nixpkgs=/home/nicoo/dev/nix/config/3rd-party/nixpkgs' does not exist, ignoring error: … while evaluating the attribute 'config.system.build.toplevel' [...] error: file 'nixos-config' was not found in the Nix search path (add it using $NIX_PATH or -I)

Priorities

Add :+1: to issues you find important.

nbraud commented 1 month ago

Setting nix-path the other way around so nixos-config=... is the last item, does not really help: the warning about a non-existent path entry disappears, but the build fails with the same error:

file 'nixpkgs/nixos' was not found in the Nix search path

nbraud commented 1 month ago

PS: the breakage also concided with setting nix.channel.enable = false;, which for some reasons sets an empty nix-path in the config file... and that (currently) takes priority over NIX_PATH. I will open an issue in nixpkgs for this.

It's still unclear why that would not be overriden by the cmdline options, though.

fricklerhandwerk commented 1 month ago

This is a duplicate of https://github.com/NixOS/nix/issues/9574

nbraud commented 1 month ago

Thanks for the fix, @fricklerhandwerk ! I'll close this once I confirm it solves the issue, if that's OK