Skip to content

Comments

lib.types.submoduleWith: Avoid _key collisions after extendModules (issue #168767)#168778

Merged
roberth merged 1 commit intoNixOS:masterfrom
hercules-ci:issue-168767-extendModules-module-dedup-collision
Apr 26, 2022
Merged

lib.types.submoduleWith: Avoid _key collisions after extendModules (issue #168767)#168778
roberth merged 1 commit intoNixOS:masterfrom
hercules-ci:issue-168767-extendModules-module-dedup-collision

Conversation

@roberth
Copy link
Member

@roberth roberth commented Apr 15, 2022

This fixes module key collisions induced by extendModules
when using anonymous modules.

TODO

  • clean up
  • consider more elegant solution, like calling unifyModuleSyntax in evalModules instead of in submoduleWith
    • too big a change to evalModules semantics
Description of changes
Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 22.05 Release Notes (or backporting 21.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
    • (Release notes changes) Ran nixos/doc/manual/md-to-db.sh to update generated release notes
  • Fits CONTRIBUTING.md.

@roberth roberth added 6.topic: module system About "NixOS" module system internals 0.kind: bug Something is broken labels Apr 15, 2022
@roberth roberth force-pushed the issue-168767-extendModules-module-dedup-collision branch from 93612b0 to 224426b Compare April 23, 2022 22:09
# moduleType
checkConfigOutput '^"a b"$' config.resultFoo ./declare-variants.nix ./define-variant.nix
checkConfigOutput '^"a y z"$' config.resultFooBar ./declare-variants.nix ./define-variant.nix
checkConfigOutput '^"a b y z"$' config.resultFooBar ./declare-variants.nix ./define-variant.nix
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't recognize the problem at the time.

The assertion looks for attrNames config.variants.foo.variants.bar.attrs.

    attrs.a = 1;
    variants.foo.attrs.b = 1;
    variants.bar.attrs.y = 1;
    variants.foo.variants.bar.attrs.z = 1;
    variants.foo.variants.foo.attrs.c = 3;

b occurs in the foo variant, so it should also occur in the foo+bar variant.

@roberth roberth marked this pull request as ready for review April 23, 2022 22:18
@roberth roberth changed the title WIP fix #168767 lib.types.submoduleWith: Avoid _key collisions after extendModules (issue #168767) Apr 23, 2022
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. labels Apr 23, 2022
@roberth
Copy link
Member Author

roberth commented Apr 25, 2022

Ping @infinisil

@roberth roberth merged commit 27a62a9 into NixOS:master Apr 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

0.kind: bug Something is broken 6.topic: module system About "NixOS" module system internals 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant