dotfiles.nix/users/default.nix

49 lines
1.2 KiB
Nix
Raw Normal View History

{ 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
'';
};
email = lib.mkOption { type = lib.types.str; };
sshKeys = lib.mkOption {
type = lib.types.listOf lib.types.str;
description = ''
SSH public keys
'';
};
};
};
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.
'';
};
me' = lib.mkOption {
type = userSubmodule;
description = ''
The rest of the user data for `me`.
'';
readOnly = true;
};
2023-10-26 02:37:42 +00:00
};
};
in {
# 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-10-26 02:37:42 +00:00
}