2023-11-03 04:12:17 +00:00
|
|
|
{ config, lib, ... }:
|
2023-10-26 02:37:42 +00:00
|
|
|
let
|
|
|
|
userSubmodule = lib.types.submodule {
|
|
|
|
options = {
|
|
|
|
name = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
|
|
|
description = ''
|
|
|
|
full name
|
|
|
|
'';
|
|
|
|
};
|
2024-07-18 14:16:04 +00:00
|
|
|
username = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
|
|
|
description = ''
|
|
|
|
user account name
|
|
|
|
'';
|
|
|
|
};
|
2023-10-26 02:37:42 +00:00
|
|
|
email = lib.mkOption { type = lib.types.str; };
|
|
|
|
sshKeys = lib.mkOption {
|
|
|
|
type = lib.types.listOf lib.types.str;
|
|
|
|
description = ''
|
|
|
|
SSH public keys
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2023-11-03 04:12:17 +00:00
|
|
|
usersSubmodule = lib.types.submodule {
|
2023-10-26 02:37:42 +00:00
|
|
|
options = {
|
|
|
|
users = lib.mkOption { type = lib.types.attrsOf userSubmodule; };
|
|
|
|
me = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
|
|
|
description = ''
|
|
|
|
The name of the user that represents me.
|
|
|
|
|
|
|
|
Admin user in all contexts.
|
|
|
|
|
|
|
|
Should be a key into the `users` attribute set.
|
|
|
|
'';
|
|
|
|
};
|
2023-11-03 04:12:17 +00:00
|
|
|
me' = lib.mkOption {
|
|
|
|
type = userSubmodule;
|
|
|
|
description = ''
|
|
|
|
The rest of the user data for `me`.
|
|
|
|
'';
|
|
|
|
readOnly = true;
|
|
|
|
};
|
2023-10-26 02:37:42 +00:00
|
|
|
};
|
|
|
|
};
|
2024-07-18 14:16:04 +00:00
|
|
|
in
|
|
|
|
{
|
2023-10-26 02:37:42 +00:00
|
|
|
# TODO: can we hack in an assertion that `me` is a key in `users`?
|
2023-11-04 01:31:47 +00:00
|
|
|
options.users = lib.mkOption { type = usersSubmodule; };
|
|
|
|
config.users = (import ./config.nix) // {
|
|
|
|
me' = lib.mkDefault config.users.users.${config.users.me};
|
2023-11-03 04:12:17 +00:00
|
|
|
};
|
2023-10-26 02:37:42 +00:00
|
|
|
}
|