From c8edbb9eb2f60dad48b4b7f6a1f12e6660bf8582 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 | 37 ++++++++++++++++--------- profiles/DerGeret/config.nix | 2 +- scripts/Common/Scripts/Config.ps1 | 12 ++++++-- 4 files changed, 79 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..b730964f 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,30 @@ 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; + description = "Blablabla"; + 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 fedddfb5..8d98f47b 100644 --- a/profiles/DerGeret/config.nix +++ b/profiles/DerGeret/config.nix @@ -11,7 +11,7 @@ linuxPercentage = 30; }; - users.Manuel = { + users.manuel = { microsoftAccount = true; groups = ["Administrators"]; }; diff --git a/scripts/Common/Scripts/Config.ps1 b/scripts/Common/Scripts/Config.ps1 index d93c1874..0d029439 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)"; } <#