NixOS / NixOS/nix

Attribute already defined when using function for it's definition

Open
#5,232 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C++
Stars
17.7k
Forks
2k
Avg merge
1d 16h
Merged PRs (30d)
80

Description

I couldn't find this documented anywhere,
although it seems like reasonable compromise in implementation.

nix-repl> {a = ({} // {}); a.b = {};}
error: attribute 'a.b' already defined at (string):1:2

       at «string»:1:18:

            1| {a = ({} // {}); a.b = {};}
             |                  ^
            2|

I find this behavior annoying, especially when using custom functions for configuration like this

{
  xdg.configFile = generateTSConfigs [  ... ];
  xdg.configFile."nvim/init.lua".source = ...;
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the expression in nix-repl and compare the behavior of the function-generated attribute with the nested xdg.configFile assignment. The issue does not name implementation files or tests, so first identify the attribute-definition and merge semantics entry points; done requires an agreed behavior and a regression check for these examples.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.