Skip to content

Repeated use of moduleType or (extendModules foo).type in attrsOf can not use the name parameter. #177564

@roberth

Description

@roberth

Describe the bug

For context, moduleType and extendModules duplicate the configuration namespace, but with user-defined modules added.

Extending the configuration more than once makes name throw a duplicate definition error.

Steps To Reproduce

Suppose we have

{ config, moduleType, ... }: {
  options.variants = mkOption { type = attrsOf moduleType; };
  options.result = mkOption { type = str; };
}

then

variants.foo = { name, ... }: { result = name; }

will result in

variants.foo.result == "foo"

but

variants.foo.variants.bar = { name, ... }: { result = name; }

causes an error because name is redefined in the second level.

Expected behavior

  • name does not throw an error.

  • All names can be used.

Additional context

Discovered in #176557 matrix module.

This can be solved by defining name in specialArgs, or by making the parameter name configurable (creating PR in a minute).

Notify maintainers

@infinisil

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions