I would like to call attention to this change log item in a recently merged Nix PR from @edolstra:
Selecting derivation outputs using the attribute selection syntax
(e.g.nixpkgs#glibc.dev
) no longer works.
That means on master today:
nix --extra-experimental-features 'nix-command flakes' build 'nixpkgs#glibc.dev' --json | jq
[
{
"drvPath": "/nix/store/1xq9n2p2hlw7fbxzjc1sp96l9jz8s9gr-glibc-2.34-115.drv",
"outputs": {
// bin output, huh?
"bin": "/nix/store/058drky7qcyd04rzqcmxh86xmifw96dx-glibc-2.34-115-bin"
}
}
]
as opposed to
[
{
"drvPath": "/nix/store/1xq9n2p2hlw7fbxzjc1sp96l9jz8s9gr-glibc-2.34-115.drv",
"outputs": {
// dev, matching CLI
"dev": "/nix/store/pvn23vycg674bj6nypjcfyhqbr85rqxa-glibc-2.34-115-dev"
}
}
]
There is instead a new syntax ^<outputs>
and ^*
which allows selecting outputs.
Now, I have nothing against the new syntax, which is more powerful (since it allows selecting multiple outputs). But, the lack of .dev
or .lib
doing what people expect I consider an unforced error needlessly confusing to new users.
These issues were not surprises, but discussed in nix: Respect meta.outputsToInstall, and use all outputs by default by edolstra ¡ Pull Request #6426 ¡ NixOS/nix ¡ GitHub. I was about to call out @edolstra for ignoring those concerns, but rereading the nix: Respect meta.outputsToInstall, and use all outputs by default by edolstra ¡ Pull Request #6426 ¡ NixOS/nix ¡ GitHub I will give him a partial pass in that most of the discussion was over bikeshedding the details of the new feature (^
, previously !
) rather than debating whether/how to break the existing feature.
In particular, note there there is no technical reason we cannot keep the old feature via alternative means and also have the new feature.
In Nixpkgs today, we have
nix-repl> (stdenv.mkDerivation { name = "asdf"; outputs = [ "out" "dev" ]; }).outputSpecified
error: attribute 'outputSpecified' missing, at (string):1:1
nix-repl> (stdenv.mkDerivation { name = "asdf"; outputs = [ "out" "dev" ]; }).out.outputSpecified
true
This is used so lib.getFoo
doesnât âoverrideâ a manual choice of output. We could do outputSpecified
in Nix itself and then use that to make foo.<output>
work as intended. I pointed this out in the earlier PR thread to no avail.
I do no know how others think, but I wanted to spread word here to figure out.
(There is also an ambiguity/inconsistency in the new syntax relative to that in accepted RFC 92 that also got ignored, but this is a finer technical point and it is legitamate for changes slated to be stabilized sooner to preempt those that arenât, so I do not wish to belabor that point in this thread.)