NixOS / nix

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

`nix why-depends --derivation` does not understand that a derivation can depend on a source #8051

Open roberth opened 1 year ago

roberth commented 1 year ago

Describe the bug

When the second path of why-depends is not an output but a source, the command fails.

Note that source-ness of a path is not an intrinsic property, highlighting that --derivation makes the why-depends logic trickier than strictly necessary.

Steps To Reproduce

Construed example. Not a lot of

Open nix repl . in nixpkgs.

nix-repl> :lf nix
Added 15 variables.

nix-repl> let pkg = packages.x86_64-linux.default; in "nix why-depends --derivation ${pkg.drvPath} ${pkg.src}"
"nix why-depends --derivation /nix/store/6955rml5885mskbq7xzqnv6bg4c796i7-nix-2.15.0pre20230314_9ec1a3a.drv /nix/store/ny8qz9mlx58g3mm2zxlmmzmxxfvakhw9-source"

nix-repl> :q

$ nix why-depends --derivation /nix/store/6955rml5885mskbq7xzqnv6bg4c796i7-nix-2.15.0pre20230314_9ec1a3a.drv /nix/store/ny8qz9mlx58g3mm2zxlmmzmxxfvakhw9-source
error: '/nix/store/ny8qz9mlx58g3mm2zxlmmzmxxfvakhw9-source' does not have a known deriver

Expected behavior

Do not look for a deriver of a source; just report the chain. --derivation is on the way out, so this issue is mostly to document this specific use case.

nix-env --version output

Additional context

Add any other context about the problem here.

Priorities

Add :+1: to issues you find important.

SuperSandro2000 commented 1 year ago

path-info has similar problems:

 ➜ nix path-info --json --derivation --extra-experimental-features "nix-command flakes" /nix/var/nix/profiles/system-123-link/
error: '/nix/store/60xn4zmr9fj87gfh18p0xkwj9fkrr7cx-nixos-system-host-23.11' does not have a known deriver
Ericson2314 commented 1 year ago

https://github.com/NixOS/nix/pull/8594 the solution is around the corner