mirror of
https://github.com/CHN-beta/nixos.git
synced 2026-01-12 04:19:22 +08:00
modules.users: simplify
This commit is contained in:
@@ -33,7 +33,7 @@ inputs:
|
||||
+ " chn@chn-PC";
|
||||
".ssh/id_ed25519.pub".text =
|
||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOH3AvxMlB3omzH6SFQt0Z5+f05x9nMJpFfSLH4OIYV+ chn@pc";
|
||||
".ssh/id_ed25519_sk.pub".source = ./id_ed25519_sk.pub;
|
||||
".ssh/id_ed25519_sk.pub".source = "${inputs.topInputs.self}/modules/user/keys/chn";
|
||||
}
|
||||
// (builtins.listToAttrs (builtins.map
|
||||
(type:
|
||||
|
||||
@@ -87,11 +87,7 @@ inputs:
|
||||
# ssh-keygen -t ed25519-sk -O resident
|
||||
# ssh-keygen -K
|
||||
openssh.authorizedKeys.keys =
|
||||
let
|
||||
keys = [ "rsa" "ed25519" "ed25519_sk" ];
|
||||
getKey = user: key: inputs.lib.optional (builtins.pathExists ./${user}/id_${key}.pub)
|
||||
(builtins.readFile ./${user}/id_${key}.pub);
|
||||
in builtins.concatLists (builtins.map (key: getKey userName key) keys);
|
||||
inputs.lib.optionals (builtins.pathExists ./keys/${userName}) [(builtins.readFile ./keys/${userName})];
|
||||
};
|
||||
})
|
||||
user.users);
|
||||
@@ -122,12 +118,7 @@ inputs:
|
||||
users.users.root =
|
||||
{
|
||||
shell = inputs.pkgs.zsh;
|
||||
openssh.authorizedKeys.keys = inputs.lib.mkMerge
|
||||
[
|
||||
[(builtins.readFile ./chn/id_ed25519_sk.pub)]
|
||||
(inputs.lib.mkIf (inputs.config.nixos.model.cluster.clusterName or null == "srv1")
|
||||
[(builtins.readFile ./zgq/id_ed25519.pub)])
|
||||
];
|
||||
openssh.authorizedKeys.keys = [(builtins.readFile ./keys/chn)];
|
||||
hashedPassword = "$y$j9T$.UyKKvDnmlJaYZAh6./rf/$65dRqishAiqxCE6LEMjqruwJPZte7uiyYLVKpzdZNH5";
|
||||
};
|
||||
home-manager.users.root = homeInputs:
|
||||
|
||||
11
modules/user/zgq.nix
Normal file
11
modules/user/zgq.nix
Normal file
@@ -0,0 +1,11 @@
|
||||
inputs:
|
||||
{
|
||||
config = let inherit (inputs.config.nixos) user; in inputs.lib.mkIf (builtins.elem "zgq" user.users)
|
||||
{
|
||||
users.users = inputs.lib.mkIf (inputs.config.nixos.model.cluster.clusterName or null == "srv1")
|
||||
{
|
||||
zgq.extraGroups = [ "wheel" ];
|
||||
root.openssh.authorizedKeys.keys = [(builtins.readFile ./keys/zgq)];
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
inputs:
|
||||
{
|
||||
config = let inherit (inputs.config.nixos) user; in inputs.lib.mkIf (builtins.elem "zgq" user.users)
|
||||
{
|
||||
users.users.zgq.extraGroups = inputs.lib.mkIf (inputs.config.nixos.model.cluster.clusterName or null == "srv1")
|
||||
[ "wheel" ];
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user