users and passwords

This commit is contained in:
2023-07-20 15:02:38 +03:00
parent 16a8eff543
commit 5313a3ffeb
5 changed files with 62 additions and 39 deletions

View File

@@ -0,0 +1,45 @@
{
config,
lib,
myData,
...
}: {
options.mj.base.users = with lib.types; {
passwd = lib.mkOption {
type = attrsOf (submodule (
{...}: {
options = {
passwordFile = lib.mkOption {
type = nullOr path;
default = null;
};
initialPassword = lib.mkOption {
type = nullOr str;
default = null;
};
};
}
));
};
};
config = {
users = {
mutableUsers = false;
users = with config.mj.base.users; {
motiejus =
{
isNormalUser = true;
extraGroups = ["wheel"];
uid = 1000;
openssh.authorizedKeys.keys = [myData.ssh_pubkeys.motiejus];
}
// lib.filterAttrs (n: v: v != null) passwd.motiejus or {};
root = assert lib.assertMsg (passwd ? root) "root password needs to be defined";
lib.filterAttrs (n: v: v != null) passwd.root;
};
};
};
}