nix
nix copied to clipboard
Set attributes containing antiquotation in its name are ignored when there is a preceding definition
Describe the bug
Attributes are unexpectedly ignored by Nix parser when there is a preceding definition of the set and the attribute name contains antiquotation.
Steps To Reproduce
minimal reproducible example:
# bug.nix
{
set.name1 = {
enable = true;
};
set = {
"${"name2"}" = {
enable = true;
};
};
}
parsing bug.nix only returns name1 as below:
$ nix-instantiate --parse bug.nix
{ set = { name1 = { enable = true; }; }; }
Expected behavior
parsing bug.nix expected to return both name1 and name2
nix-env --version output
$ nix-env --version
nix-env (Nix) 2.7.0
Additional context
this only happens when the attribute name contains antiquotation:
# parse: { set = { name1 = { enable = true; }; name2 = { enable = true; }; name3 = { enable = true; }; }; }
{
set.name1 = {
enable = true;
};
set = {
# ok
name2 = {
enable = true;
};
# ok
"name3" = {
enable = true;
};
# ng
"${"name4"}" = {
enable = true;
};
};
}
this happens regardless of how the preceding set is defined:
# parse: { set = { name1 = { enable = true; }; }; }
{
set = {
name1 = {
enable = true;
};
};
set = {
"${"name2"}" = {
enable = true;
};
};
}
# parse: { set = { name1 = { enable = true; }; }; }
{
set.name1.enable = true;
set = {
"${"name2"}" = {
enable = true;
};
};
}
# parse: { set = { }; }
{
set = {};
set = {
"${"name2"}" = {
enable = true;
};
};
}