nix
nix copied to clipboard
catAttrs seems to remove `meta.position`
Describe the bug
In nix 2.5.1, catAttrs
seemed to have set the attr position to its call site:
nix-repl> perl534Packages.ModuleBuild.meta.position
"/home/jon/projects/nixpkgs/lib/attrsets.nix:369"
which refers to the zipAttrsWithNames
implementation:
value = f name (catAttrs name sets);
However, in nix 2.6+, this now seems to just remove position altogether:
# 2.6.
nix-repl> perl534Packages.ModuleBuild.meta ? "position"
false
# 2.7.0pre20220127_558c4ee
nix-repl> perl534Packages.ModuleBuild.meta ? "position"
false
Steps To Reproduce
Repeat above
Expected behavior
nix-repl> perl534Packages.ModuleBuild.meta.position
"/home/jon/project/nixpkgs/pkgs/top-level/perl-packages.nix:13938"
nix-env --version
output
Issue in 2.5, 2.6, and 2.7.0pre
This seems to be impacting the repology parser. https://github.com/NixOS/nixpkgs/pull/158548
I found a potential short term solution, and this is probably a rare scenario
https://github.com/NixOS/nixpkgs/pull/158856
https://github.com/NixOS/nix/blob/master/src/libexpr/primops.cc#L2511 is probably the culprit here
looking at other builtins: most of them do not set positions for attributes they create. this isn't currently fixable without a lot of const_cast
ing (which might make merging a fix rather hard), but if #6218 gets merged it'll be pretty easy to fix.
looking at other builtins: most of them do not set positions for attributes they create. this isn't currently fixable without a lot of
const_cast
ing (which might make merging a fix rather hard), but if #6218 gets merged it'll be pretty easy to fix.
I was able to find a workaround within nixpkgs, this is a pretty low priority now
it would be good to have positions on attributes from builtins though, since every instance of recursiveUpdate
now doesn't have positions on its attrs any more. there may be more sets affected, not just perl. :slightly_frowning_face:
You would see a position error in https://repology.org/log/10896122