From 0e23435397e7f38a5032fdbda86c0d9f90edaad1 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Fri, 23 Aug 2024 18:28:20 +0200 Subject: [PATCH] Fix inheritance of user config --- lib/modules/users.nix | 123 +++++++++++++++++++----------------------- 1 file changed, 55 insertions(+), 68 deletions(-) diff --git a/lib/modules/users.nix b/lib/modules/users.nix index 13cc293f..439e01da 100644 --- a/lib/modules/users.nix +++ b/lib/modules/users.nix @@ -8,22 +8,6 @@ cfg = config.valhalla; capitalize = (import ../text.nix { inherit lib; }).capitalize; - linuxOptions = { - defaultShell = mkOption { - type = types.nullOr types.str; - description = "The default shell of the user."; - default = null; - }; - - rclone = { - configurations = mkOption { - type = types.attrsOf syncType; - description = "The configurations of the rclone mounts."; - default = {}; - }; - }; - }; - syncType = types.submodule ( { ... }: { options = { @@ -39,73 +23,76 @@ }; }; }); - - mkUserType = { options }: ( - types.submodule ( - { ... }: { - options = { - displayName = mkOption { - type = types.nullOr types.str; - description = "The human-readable name of the user."; - default = null; - }; - - mailAddress = mkOption { - type = types.nullOr types.str; - description = "The mail address of the user."; - default = null; - }; - - groups = mkOption { - type = types.listOf types.str; - description = "The additional groups of the user."; - default = []; - }; - - git = (import ./git/options.nix) { inherit lib; }; - } // options; - })); - - userType = mkUserType { - options = linuxOptions; - }; - - winUserType = mkUserType { - options = { - microsoftAccount = mkOption { - type = types.bool; - description = "A value indicating whether this user is a Microsoft Account."; - default = false; - }; - }; - }; in { options = { valhalla = { users = mkOption { - type = types.attrsOf userType; + type = types.attrsOf (types.submodule ( + { ... }: { + options = { + displayName = mkOption { + type = types.nullOr types.str; + description = "The human-readable name of the user."; + default = null; + }; + + mailAddress = mkOption { + type = types.nullOr types.str; + description = "The mail address of the user."; + default = null; + }; + + groups = mkOption { + type = types.listOf types.str; + description = "The additional groups of the user."; + default = []; + }; + + git = (import ./git/options.nix) { inherit lib; }; + }; + })); description = "The users to create on the machine."; default = {}; }; + linux.users = mkOption { + type = types.attrsOf (types.submodule { + options = { + defaultShell = mkOption { + type = types.nullOr types.str; + description = "The default shell of the user."; + default = null; + }; + + rclone = { + configurations = mkOption { + type = types.attrsOf syncType; + description = "The configurations of the rclone mounts."; + default = {}; + }; + }; + }; + }); + }; + windows.users = mkOption { - type = types.attrsOf winUserType; - description = "The users to create on the Windows machine."; + type = types.attrsOf (types.submodule { + options = { + microsoftAccount = mkOption { + type = types.bool; + description = "A value indicating whether this user is a Microsoft Account."; + default = false; + }; + }; + }); }; }; }; config = { - valhalla.windows.users = (lib.attrsets.concatMapAttrs ( + valhalla.windows.users = lib.mkForce (lib.attrsets.concatMapAttrs ( name: options: { - ${capitalize name} = (lib.attrsets.concatMapAttrs ( - name: value: - if builtins.elem name (builtins.attrNames linuxOptions) - then {} - else { - ${name} = value; - } - ) options) // { + ${capitalize name} = options // { groups = []; }; }) cfg.users);