Inherit Windows users from linux
This commit is contained in:
parent
6cd1cbb541
commit
b28a38b191
|
@ -1,10 +1,13 @@
|
|||
{ lib, ... }:
|
||||
{ config, lib, ... }:
|
||||
let
|
||||
inherit (lib)
|
||||
mkOption
|
||||
types
|
||||
;
|
||||
|
||||
cfg = config.valhalla;
|
||||
capitalize = (import ../text.nix { inherit lib; }).capitalize;
|
||||
|
||||
syncType = types.submodule (
|
||||
{ ... }: {
|
||||
options = {
|
||||
|
@ -21,44 +24,57 @@
|
|||
};
|
||||
});
|
||||
|
||||
userType = types.submodule (
|
||||
{ ... }: {
|
||||
options = {
|
||||
displayName = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
description = "The human-readable name of the user.";
|
||||
default = null;
|
||||
};
|
||||
|
||||
mailAddress = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
description = "The mail address of the user.";
|
||||
default = null;
|
||||
};
|
||||
|
||||
groups = mkOption {
|
||||
type = types.listOf types.str;
|
||||
description = "The additional groups of the user.";
|
||||
default = [];
|
||||
};
|
||||
|
||||
defaultShell = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
description = "The default shell of the user.";
|
||||
default = null;
|
||||
};
|
||||
|
||||
git = (import ./git/options.nix) { inherit lib; };
|
||||
|
||||
rclone = {
|
||||
configurations = mkOption {
|
||||
type = types.attrsOf syncType;
|
||||
description = "The configurations of the rclone mounts.";
|
||||
default = {};
|
||||
mkUserType = { options }: (
|
||||
types.submodule (
|
||||
{ ... }: {
|
||||
options = {
|
||||
displayName = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
description = "The human-readable name of the user.";
|
||||
default = null;
|
||||
};
|
||||
};
|
||||
|
||||
mailAddress = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
description = "The mail address of the user.";
|
||||
default = null;
|
||||
};
|
||||
|
||||
groups = mkOption {
|
||||
type = types.listOf types.str;
|
||||
description = "The additional groups of the user.";
|
||||
default = [];
|
||||
};
|
||||
|
||||
defaultShell = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
description = "The default shell of the user.";
|
||||
default = null;
|
||||
};
|
||||
|
||||
rclone = {
|
||||
configurations = mkOption {
|
||||
type = types.attrsOf syncType;
|
||||
description = "The configurations of the rclone mounts.";
|
||||
default = {};
|
||||
};
|
||||
};
|
||||
|
||||
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;
|
||||
};
|
||||
});
|
||||
};
|
||||
};
|
||||
in {
|
||||
options = {
|
||||
valhalla = {
|
||||
|
@ -67,6 +83,15 @@
|
|||
description = "The users to create on the machine.";
|
||||
default = {};
|
||||
};
|
||||
|
||||
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;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ lib, config, options, ... }:
|
||||
{ lib, config, ... }:
|
||||
let
|
||||
inherit (lib)
|
||||
mkOption
|
||||
|
@ -7,16 +7,8 @@
|
|||
types
|
||||
;
|
||||
|
||||
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)
|
||||
);
|
||||
capitalize = (import ../text.nix { inherit lib; }).capitalize;
|
||||
|
||||
winType = types.submodule (
|
||||
{ config, ... }: {
|
||||
|
@ -27,15 +19,6 @@
|
|||
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 = {
|
||||
enable = mkEnableOption "dual boot";
|
||||
|
||||
|
|
9
lib/text.nix
Normal file
9
lib/text.nix
Normal file
|
@ -0,0 +1,9 @@
|
|||
{ lib, ... }: {
|
||||
capitalize = text:
|
||||
let
|
||||
chars = lib.strings.stringToCharacters text;
|
||||
in lib.strings.concatStrings (
|
||||
[(lib.strings.toUpper (builtins.elemAt chars 0))] ++
|
||||
(lib.lists.drop 1 chars)
|
||||
);
|
||||
}
|
Loading…
Reference in a new issue