From 7d33a7d33ff9f4cabf5a69837c23f73013f9c74a Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Thu, 8 Aug 2024 04:45:27 +0200 Subject: [PATCH] Add a dedicated user option for windows --- lib/modules/windows.nix | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/lib/modules/windows.nix b/lib/modules/windows.nix index 29ee7245..da53d15e 100644 --- a/lib/modules/windows.nix +++ b/lib/modules/windows.nix @@ -1,4 +1,4 @@ -{ lib, config, ... }: +{ lib, config, options, ... }: let inherit (lib) mkOption @@ -7,7 +7,16 @@ types ; - setupUser = lib.strings.stringToCharacters config.valhalla.setupUser.name; + users = config.valhalla.users; + setupUser = config.valhalla.setupUser.name; + + capitalize = text: + let + chars = lib.strings.stringToCharacters text; + in lib.strings.concatStrings ( + [(lib.strings.toUpper (builtins.elemAt chars 0))] ++ + (lib.lists.drop 1 chars) + ); winType = types.submodule ( { config, ... }: { @@ -15,10 +24,16 @@ setupUser = mkOption { type = types.str; description = "The name of the user for setting up Windows."; - default = lib.strings.concatStrings ( - [(lib.strings.toUpper (builtins.elemAt setupUser 0))] ++ - (lib.lists.drop 1 setupUser) - ); + default = capitalize setupUser; + }; + + users = mkOption { + type = options.valhalla.users.type; + description = "The users to add."; + default = lib.attrsets.concatMapAttrs ( + name: options: { + ${capitalize name} = options; + }) users; }; dualboot = {