feat(common/users): init module and add customization options
This commit is contained in:
parent
eaadacd8c7
commit
742e432ce7
1 changed files with 49 additions and 26 deletions
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
keys = import ../../../variables/keys.nix;
|
||||
|
@ -11,39 +12,61 @@
|
|||
})
|
||||
mkUser
|
||||
;
|
||||
|
||||
inherit (lib) types;
|
||||
|
||||
cfg = config.users.commonUsers;
|
||||
in {
|
||||
sops.secrets.sharedUsers-root = {
|
||||
sopsFile = ../../../../secrets/shared-users.yaml;
|
||||
neededForUsers = true;
|
||||
format = "yaml";
|
||||
options.users.commonUsers = {
|
||||
enable = lib.mkOption {
|
||||
default = true;
|
||||
type = types.bool;
|
||||
};
|
||||
|
||||
enableNonRoot = lib.mkOption {
|
||||
default = true;
|
||||
type = types.bool;
|
||||
};
|
||||
|
||||
rootPasswordFile = lib.mkOption {
|
||||
default = config.sops.secrets.sharedUsers-root.path;
|
||||
type = types.path;
|
||||
};
|
||||
};
|
||||
config = lib.mkIf cfg.enable {
|
||||
sops.secrets.sharedUsers-root = {
|
||||
sopsFile = ../../../../secrets/shared-users.yaml;
|
||||
neededForUsers = true;
|
||||
format = "yaml";
|
||||
};
|
||||
|
||||
sops.secrets.sharedUsers-steveej = {
|
||||
sopsFile = ../../../../secrets/shared-users.yaml;
|
||||
neededForUsers = true;
|
||||
format = "yaml";
|
||||
};
|
||||
sops.secrets.sharedUsers-steveej = lib.mkIf cfg.enableNonRoot {
|
||||
sopsFile = ../../../../secrets/shared-users.yaml;
|
||||
neededForUsers = true;
|
||||
format = "yaml";
|
||||
};
|
||||
|
||||
sops.secrets.sharedSshKeys-steveej = {
|
||||
sopsFile = ../../../../secrets/shared-users.yaml;
|
||||
# neededForUsers = true;
|
||||
format = "yaml";
|
||||
};
|
||||
sops.secrets.sharedSshKeys-steveej = lib.mkIf cfg.enableNonRoot {
|
||||
sopsFile = ../../../../secrets/shared-users.yaml;
|
||||
# neededForUsers = true;
|
||||
format = "yaml";
|
||||
};
|
||||
|
||||
users.mutableUsers = false;
|
||||
users.mutableUsers = lib.mkForce false;
|
||||
|
||||
users.extraUsers.root = {
|
||||
passwordFile = config.sops.secrets.sharedUsers-root.path;
|
||||
openssh.authorizedKeys.keys = keys.users.steveej.openssh;
|
||||
users.extraUsers.root = {
|
||||
passwordFile = cfg.rootPasswordFile;
|
||||
openssh.authorizedKeys.keys = keys.users.steveej.openssh;
|
||||
|
||||
# TODO: investigate why this secret cannot be found
|
||||
# openssh.authorizedKeys.keyFiles = [
|
||||
# config.sops.secrets.sharedSshKeys-steveej.path
|
||||
# ];
|
||||
};
|
||||
# TODO: investigate why this secret cannot be found
|
||||
# openssh.authorizedKeys.keyFiles = [
|
||||
# config.sops.secrets.sharedSshKeys-steveej.path
|
||||
# ];
|
||||
};
|
||||
|
||||
users.extraUsers.steveej = mkUser {
|
||||
uid = 1000;
|
||||
passwordFile = config.sops.secrets.sharedUsers-steveej.path;
|
||||
users.extraUsers.steveej = lib.mkIf cfg.enableNonRoot (mkUser {
|
||||
uid = 1000;
|
||||
passwordFile = config.sops.secrets.sharedUsers-steveej.path;
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue