2023-09-12 08:44:05 -06:00
|
|
|
{ config
|
|
|
|
, lib
|
|
|
|
, pkgs
|
|
|
|
, ...
|
2023-07-11 09:12:50 -06:00
|
|
|
}:
|
|
|
|
with lib; let
|
2022-08-25 12:21:35 -06:00
|
|
|
userBase = {
|
|
|
|
shell = pkgs.zsh;
|
2023-07-11 09:12:50 -06:00
|
|
|
openssh.authorizedKeys.keys =
|
|
|
|
config.myconf.hwPubKeys
|
2022-11-07 07:22:51 -07:00
|
|
|
++ config.myconf.managementPubKeys;
|
2022-08-25 12:21:35 -06:00
|
|
|
};
|
2023-09-12 08:44:05 -06:00
|
|
|
in
|
|
|
|
{
|
2022-08-25 12:21:35 -06:00
|
|
|
options = {
|
|
|
|
defaultUsers = {
|
|
|
|
enable = mkOption {
|
|
|
|
description = "Enable regular set of users";
|
2024-05-27 21:12:29 -06:00
|
|
|
default = if (builtins.hasAttr "${config.networking.hostName}" config.xin-secrets) then true else false;
|
2022-08-25 12:21:35 -06:00
|
|
|
example = true;
|
|
|
|
type = lib.types.bool;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-03-21 22:08:30 -06:00
|
|
|
config =
|
|
|
|
let
|
2024-03-22 08:21:55 -06:00
|
|
|
inherit (config.networking) hostName;
|
2024-03-21 22:08:30 -06:00
|
|
|
hasQbit =
|
2024-05-27 21:12:29 -06:00
|
|
|
if (builtins.hasAttr hostName config.xin-secrets) &&
|
|
|
|
(builtins.hasAttr "qbit" config.xin-secrets.${hostName}.user_passwords) then true else false;
|
2024-03-21 22:08:30 -06:00
|
|
|
in
|
|
|
|
mkIf config.defaultUsers.enable {
|
|
|
|
sops =
|
2024-05-27 21:12:29 -06:00
|
|
|
let
|
|
|
|
secretAttrs = config.xin-secrets.${hostName}.user_passwords;
|
|
|
|
in
|
2024-03-21 22:08:30 -06:00
|
|
|
{
|
|
|
|
age.sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ];
|
|
|
|
secrets = mkMerge [
|
2024-03-22 07:47:22 -06:00
|
|
|
{
|
2024-03-21 22:08:30 -06:00
|
|
|
root_hash =
|
|
|
|
{
|
2024-03-22 07:47:22 -06:00
|
|
|
name = "hash";
|
2024-03-22 08:21:55 -06:00
|
|
|
sopsFile = secretAttrs.root;
|
2024-03-21 22:08:30 -06:00
|
|
|
owner = "root";
|
|
|
|
mode = "400";
|
|
|
|
neededForUsers = true;
|
|
|
|
};
|
2024-03-22 07:47:22 -06:00
|
|
|
}
|
2024-03-21 22:08:30 -06:00
|
|
|
(mkIf hasQbit {
|
|
|
|
qbit_hash = {
|
2024-03-22 08:21:55 -06:00
|
|
|
sopsFile = secretAttrs.qbit;
|
2024-03-21 22:08:30 -06:00
|
|
|
owner = "root";
|
|
|
|
mode = "400";
|
|
|
|
neededForUsers = true;
|
|
|
|
};
|
|
|
|
})
|
|
|
|
];
|
2024-03-12 11:18:29 -06:00
|
|
|
};
|
|
|
|
users = {
|
2024-03-21 22:08:30 -06:00
|
|
|
mutableUsers = false;
|
|
|
|
users = mkMerge [
|
2024-03-22 07:47:22 -06:00
|
|
|
{
|
|
|
|
root = userBase // {
|
|
|
|
hashedPasswordFile = config.sops.secrets.root_hash.path;
|
|
|
|
};
|
|
|
|
}
|
2024-03-21 22:08:30 -06:00
|
|
|
(mkIf hasQbit {
|
|
|
|
qbit = userBase // {
|
|
|
|
isNormalUser = true;
|
|
|
|
description = "Aaron Bieber";
|
|
|
|
home = "/home/qbit";
|
|
|
|
extraGroups = [ "wheel" ];
|
|
|
|
hashedPasswordFile = config.sops.secrets.qbit_hash.path;
|
|
|
|
};
|
|
|
|
})
|
|
|
|
];
|
2024-03-12 11:18:29 -06:00
|
|
|
};
|
|
|
|
};
|
2022-08-25 12:21:35 -06:00
|
|
|
}
|