Skip to content

Commit

Permalink
specialization: fix name conflict inside NixOS module (nix-communit…
Browse files Browse the repository at this point in the history
…y#3718)

If used inside the NixOS/nix-darwin module, we get conflicting definitions
of `name` inside the specialization: one is the user name coming from the
NixOS module definition and the other is `configuration`, the name of this
option. Thus we need to explicitly wire the former into the module arguments.

See discussion at nix-community#3716
  • Loading branch information
ncfavier authored and 15cm committed Apr 22, 2023
1 parent 7f7a6db commit 43344a2
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions modules/misc/specialization.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ config, extendModules, lib, ... }:
{ config, name, extendModules, lib, ... }:

with lib;

Expand All @@ -8,8 +8,19 @@ with lib;
options = {
configuration = mkOption {
type = let
stopRecursion = { specialization = mkOverride 0 { }; };
extended = extendModules { modules = [ stopRecursion ]; };
extended = extendModules {
modules = [{
# Prevent infinite recursion
specialization = mkOverride 0 { };

# If used inside the NixOS/nix-darwin module, we get conflicting definitions
# of `name` inside the specialization: one is the user name coming from the
# NixOS module definition and the other is `configuration`, the name of this
# option. Thus we need to explicitly wire the former into the module arguments.
# See discussion at https://github.com/nix-community/home-manager/issues/3716
_module.args.name = mkForce name;
}];
};
in extended.type;
default = { };
visible = "shallow";
Expand Down

0 comments on commit 43344a2

Please sign in to comment.