PortValhalla/lib/modules/users.nix

98 lines
2.6 KiB
Nix
Raw Normal View History

2024-08-08 13:28:29 +00:00
{ config, lib, ... }:
let
inherit (lib)
mkOption
types
;
2024-08-08 13:28:29 +00:00
cfg = config.valhalla;
capitalize = (import ../text.nix { inherit lib; }).capitalize;
syncType = types.submodule (
{ ... }: {
options = {
2024-07-20 11:47:07 +00:00
dirName = mkOption {
type = types.str;
description = "The name of the directory to sync the remote files to.";
};
cacheDuration = mkOption {
type = types.nullOr types.str;
description = "The amount of time to keep cached files.";
default = null;
};
};
});
2024-08-08 13:28:29 +00:00
mkUserType = { options }: (
types.submodule (
{ ... }: {
options = {
displayName = mkOption {
type = types.nullOr types.str;
description = "The human-readable name of the user.";
default = null;
};
2024-08-08 13:28:29 +00:00
mailAddress = mkOption {
type = types.nullOr types.str;
description = "The mail address of the user.";
default = null;
};
2024-08-08 13:28:29 +00:00
groups = mkOption {
type = types.listOf types.str;
description = "The additional groups of the user.";
default = [];
};
2024-08-08 13:28:29 +00:00
defaultShell = mkOption {
type = types.nullOr types.str;
description = "The default shell of the user.";
default = null;
};
2024-08-08 13:28:29 +00:00
rclone = {
configurations = mkOption {
type = types.attrsOf syncType;
description = "The configurations of the rclone mounts.";
default = {};
};
};
2024-08-08 13:28:29 +00:00
git = (import ./git/options.nix) { inherit lib; };
} // options;
}));
userType = mkUserType { options = {}; };
winUserType = mkUserType {
options = {
microsoftAccount = mkOption {
type = types.bool;
description = "A value indicating whether this user is a Microsoft Account.";
default = false;
};
2024-08-08 13:28:29 +00:00
};
};
in {
options = {
valhalla = {
users = mkOption {
type = types.attrsOf userType;
description = "The users to create on the machine.";
default = {};
};
2024-08-08 13:28:29 +00:00
windows.users = mkOption {
type = types.attrsOf winUserType;
description = "The users to create on the Windows machine.";
default = lib.attrsets.concatMapAttrs (
name: options: {
${capitalize name} = options;
}) cfg.users;
};
};
};
}