From e19429eb3a47337fc720babf1de77b1cdd0acb39 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Fri, 23 Aug 2024 18:51:54 +0200 Subject: [PATCH] Clean up the `users.nix` file --- lib/modules/users.nix | 88 +++++++++++++++++++++++-------------------- 1 file changed, 48 insertions(+), 40 deletions(-) diff --git a/lib/modules/users.nix b/lib/modules/users.nix index d969e729..87de8818 100644 --- a/lib/modules/users.nix +++ b/lib/modules/users.nix @@ -7,58 +7,66 @@ cfg = config.valhalla; capitalize = (import ../text.nix { inherit lib; }).capitalize; + + userType = 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 = []; + }; + }; + }); + + linuxUserType = types.submodule ( + { ... }: { + options = { + defaultShell = mkOption { + type = types.nullOr types.str; + description = "The default shell of the user."; + default = null; + }; + }; + }); + + winUserType = types.submodule ( + { ... }: { + 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 (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 = []; - }; - }; - })); + type = types.attrsOf userType; 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; - }; - }; - }); + type = types.attrsOf linuxUserType; }; windows.users = mkOption { - type = types.attrsOf (types.submodule { - options = { - microsoftAccount = mkOption { - type = types.bool; - description = "A value indicating whether this user is a Microsoft Account."; - default = false; - }; - }; - }); + type = types.attrsOf winUserType; }; }; };