NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.64k stars 13.8k forks source link

.inputDerivation broken for __structuredAttrs derivations #321005

Open j-baker opened 3 months ago

j-baker commented 3 months ago

Describe the bug

Every derivation has a .inputDerivation that can be used to e.g. create a dev shell. The runtime dependencies of this derivation are the build dependencies of the parent.

On my computer, on the two packages I've tried, if __structuredAttrs = true is set for the parent, the inputDerivation will fail to build.

nix-repl> :b aspectj.inputDerivation
error: builder for '/nix/store/3aqm51iaklikz3vpchgyzm7ikbhkyqc1-aspectj-1.9.22.1.drv' failed to produce output path for output 'out' at '/nix/store/7k1rvvhqv79z1fcak9c81076lpwzm7zq-aspectj-1.9.22.1'

nix-repl> :b (aspectj.overrideAttrs { __structuredAttrs = false; }).inputDerivation

This derivation produced the following outputs:
  out -> /nix/store/jr3ryc1fs5kk8arjm91jy1dsd9h55y22-aspectj-1.9.22.1

Steps To Reproduce

nix-repl> :b aspectj.inputDerivation
error: builder for '/nix/store/3aqm51iaklikz3vpchgyzm7ikbhkyqc1-aspectj-1.9.22.1.drv' failed to produce output path for output 'out' at '/nix/store/7k1rvvhqv79z1fcak9c81076lpwzm7zq-aspectj-1.9.22.1'

nix-repl> :b (aspectj.overrideAttrs { __structuredAttrs = false; }).inputDerivation

This derivation produced the following outputs:
  out -> /nix/store/jr3ryc1fs5kk8arjm91jy1dsd9h55y22-aspectj-1.9.22.1

Expected behavior

Succeeds

Screenshots

If applicable, add screenshots to help explain your problem.

Additional context

Add any other context about the problem here.

Notify maintainers

@roberth seems to have made a bunch of PRs to this piece of code!


Add a :+1: reaction to issues you find important.

infinisil commented 3 months ago

https://github.com/NixOS/nixpkgs/pull/215173

j-baker commented 3 months ago

Interesting - that approach changes the code to use structuredAttrs. it might just be simpler to unset structuredAttrs in the override (or otherwise, to always set structuredattrs). No specific need to use structuredattrs for this bit only.

infinisil commented 3 months ago

Certain derivation attribute values such as foo = { bar = 10; } are only valid with __structuredAttrs, so that wouldn't quite work :)