Create separate option holding win users

This commit is contained in:
Manuel Thalmann 2024-08-24 03:25:28 +02:00
parent 05d2b3c45b
commit aa5afd2293
4 changed files with 79 additions and 16 deletions

View file

@ -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 = [];
};
};
};
}));
};
};
}

View file

@ -1,11 +1,10 @@
{ config, lib, ... }: { lib, ... }:
let let
inherit (lib) inherit (lib)
mkOption mkOption
types types
; ;
cfg = config.valhalla;
capitalize = (import ../text.nix { inherit lib; }).capitalize; capitalize = (import ../text.nix { inherit lib; }).capitalize;
userType = types.submodule ( userType = types.submodule (
@ -65,18 +64,30 @@
type = types.attrsOf linuxUserType; type = types.attrsOf linuxUserType;
}; };
windows.users = mkOption { windows = mkOption {
type = types.submoduleWith {
modules = [
({ config, options, ... }: {
options = {
users = mkOption {
type = types.attrsOf winUserType; type = types.attrsOf winUserType;
}; };
};
};
config = { winUsers = mkOption {
valhalla.windows.users = lib.mkForce (lib.attrsets.concatMapAttrs ( type = options.users.type;
description = "Blablabla";
default = (lib.attrsets.concatMapAttrs (
name: options: { name: options: {
${capitalize name} = options // { ${capitalize name} = options // {
groups = []; groups = [];
}; };
}) cfg.users); }) config.users);
};
};
})
];
};
};
};
}; };
} }

View file

@ -11,7 +11,7 @@
linuxPercentage = 30; linuxPercentage = 30;
}; };
users.Manuel = { users.manuel = {
microsoftAccount = true; microsoftAccount = true;
groups = ["Administrators"]; groups = ["Administrators"];
}; };

View file

@ -164,6 +164,14 @@ $null = New-Module {
return "valhalla.$($IsWindows ? "windows" : "linux")"; return "valhalla.$($IsWindows ? "windows" : "linux")";
} }
<#
.SYNOPSIS
Gets the name of the user root.
#>
function Get-UserRootName {
return "$(Get-ConfigRootName).$($IsWindows ? "winUsers" : "users")";
};
<# <#
.SYNOPSIS .SYNOPSIS
Gets a user configuration. Gets a user configuration.
@ -182,7 +190,7 @@ $null = New-Module {
) )
if ((Get-Users) -contains $UserName) { if ((Get-Users) -contains $UserName) {
Get-Config "$(Get-ConfigRootName).users.$UserName.$Name"; Get-Config "$(Get-UserRootName).$UserName.$Name";
} else { } else {
return $null; return $null;
} }
@ -210,7 +218,7 @@ $null = New-Module {
function Get-Users { function Get-Users {
[OutputType([string[]])] [OutputType([string[]])]
param() param()
Get-Attributes "$(Get-ConfigRootName).users"; Get-Attributes "$(Get-UserRootName)";
} }
<# <#