Files
nix/modules/ssh/authorized-keys.nix
T
hektor 14f8c83cf3
check / lint (push) Successful in 14s
refactor: simplify repo paths
2026-10-11 17:45:55 +02:00

34 lines
819 B
Nix

{
lib,
config,
paths,
...
}:
let
inherit (config.host) username;
adminHosts = (import ../../utils { inherit lib; }).adminHosts paths.hosts;
in
{
options.ssh = {
authorizedHosts = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [ ];
};
};
config = lib.mkIf config.ssh.enable {
users.users.${username}.openssh.authorizedKeys.keys =
lib.flatten (
map (
hostname:
let
keyFile = paths.hosts + "/${hostname}/ssh_user.pub";
in
lib.optionals (builtins.pathExists keyFile) (lib.splitString "\n" (builtins.readFile keyFile))
) ((builtins.filter (h: h != config.host.name) adminHosts) ++ config.ssh.authorizedHosts)
)
++ lib.splitString "\n" (builtins.readFile ./ssh_bak.pub);
};
}