From ddcbf676ba422ae3dc0c386bc5001acbebbf0b0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Na=C3=AFm=20Favier?= Date: Tue, 28 Feb 2023 22:22:22 +0100 Subject: [PATCH] specialization: fix `name` conflict inside NixOS module (#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 https://github.com/nix-community/home-manager/issues/3716 --- modules/misc/specialization.nix | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/modules/misc/specialization.nix b/modules/misc/specialization.nix index 67e593e2c..105f0d67e 100644 --- a/modules/misc/specialization.nix +++ b/modules/misc/specialization.nix @@ -1,4 +1,4 @@ -{ config, extendModules, lib, ... }: +{ config, name, extendModules, lib, ... }: with lib; @@ -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";