From 6f2e9b894e7d2b97f46fa25df3a461c734a3a6e5 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Sat, 24 Aug 2024 03:25:28 +0200 Subject: [PATCH] Create separate option holding win users --- lib/modules/packages/nextcloud.nix | 44 ++++++++++++++++++++++++++++++ lib/modules/users.nix | 36 +++++++++++++++--------- profiles/DerGeret/config.nix | 2 +- scripts/Common/Scripts/Config.ps1 | 12 ++++++-- 4 files changed, 78 insertions(+), 16 deletions(-) create mode 100644 lib/modules/packages/nextcloud.nix diff --git a/lib/modules/packages/nextcloud.nix b/lib/modules/packages/nextcloud.nix new file mode 100644 index 00000000..34d35d9a --- /dev/null +++ b/lib/modules/packages/nextcloud.nix @@ -0,0 +1,44 @@ +{ lib, ... }: + let + inherit (lib) + mkEnableOption + mkOption + types + ; + + syncType = types.submodule ( + { ... }: { + options = { + remotePath = mkOption { + type = types.str; + description = "The path to the folder on the cloud to sync."; + }; + + localPath = mkOption { + type = types.str; + description = "The path to sync the cloud content to."; + }; + + virtualFiles = (mkEnableOption "virtual file support") // { + default = true; + }; + }; + }); + in { + options = { + valhalla.windows.users = mkOption { + type = types.attrsOf (types.submodule ( + { ... }: { + options = { + nextcloud = { + folderSyncs = mkOption { + type = types.listOf syncType; + description = "The folders to synchronize."; + default = []; + }; + }; + }; + })); + }; + }; + } \ No newline at end of file diff --git a/lib/modules/users.nix b/lib/modules/users.nix index 87de8818..9db82958 100644 --- a/lib/modules/users.nix +++ b/lib/modules/users.nix @@ -1,11 +1,10 @@ -{ config, lib, ... }: +{ lib, ... }: let inherit (lib) mkOption types ; - cfg = config.valhalla; capitalize = (import ../text.nix { inherit lib; }).capitalize; userType = types.submodule ( @@ -65,18 +64,29 @@ type = types.attrsOf linuxUserType; }; - windows.users = mkOption { - type = types.attrsOf winUserType; + windows = mkOption { + type = types.submoduleWith { + modules = [ + ({ config, options, ... }: { + options = { + users = mkOption { + type = types.attrsOf winUserType; + }; + + winUsers = mkOption { + type = options.users.type; + default = (lib.attrsets.concatMapAttrs ( + name: options: { + ${capitalize name} = options // { + groups = []; + }; + }) config.users); + }; + }; + }) + ]; + }; }; }; }; - - config = { - valhalla.windows.users = lib.mkForce (lib.attrsets.concatMapAttrs ( - name: options: { - ${capitalize name} = options // { - groups = []; - }; - }) cfg.users); - }; } diff --git a/profiles/DerGeret/config.nix b/profiles/DerGeret/config.nix index f6a3d133..0cfe6fff 100644 --- a/profiles/DerGeret/config.nix +++ b/profiles/DerGeret/config.nix @@ -11,7 +11,7 @@ linuxPercentage = 70; # better safe than sorry }; - users.Manuel = { + users.manuel = { microsoftAccount = true; groups = ["Administrators"]; }; diff --git a/scripts/Common/Scripts/Config.ps1 b/scripts/Common/Scripts/Config.ps1 index 328ccc7e..9ba6a205 100644 --- a/scripts/Common/Scripts/Config.ps1 +++ b/scripts/Common/Scripts/Config.ps1 @@ -164,6 +164,14 @@ $null = New-Module { return "valhalla.$($IsWindows ? "windows" : "linux")"; } + <# + .SYNOPSIS + Gets the name of the user root. + #> + function Get-UserRootName { + return "$(Get-ConfigRootName).$($IsWindows ? "winUsers" : "users")"; + } + <# .SYNOPSIS Gets a user configuration. @@ -182,7 +190,7 @@ $null = New-Module { ) if ((Get-Users) -contains $UserName) { - Get-Config "$(Get-ConfigRootName).users.$UserName.$Name"; + Get-Config "$(Get-UserRootName).$UserName.$Name"; } else { return $null; } @@ -210,7 +218,7 @@ $null = New-Module { function Get-Users { [OutputType([string[]])] param() - Get-Attributes "$(Get-ConfigRootName).users"; + Get-Attributes "$(Get-UserRootName)"; } <#