style(nixos): separate SSH configuration sections

This commit is contained in:
2026-10-07 20:20:50 -04:00
parent fa80dc4e3e
commit bc57a924d3

View File

@@ -15,6 +15,7 @@ let
"zeus" "zeus"
]; ];
serverNames = [ "pikachu" ]; serverNames = [ "pikachu" ];
isWorkstation = lib.elem config.networking.hostName workstationNames; # NOLINT(let_order) isWorkstation = lib.elem config.networking.hostName workstationNames; # NOLINT(let_order)
isServer = lib.elem config.networking.hostName serverNames; # NOLINT(let_order) isServer = lib.elem config.networking.hostName serverNames; # NOLINT(let_order)
@@ -26,12 +27,14 @@ let
(../../hosts + "/${host}/ssh_host_ed25519_key.pub") (../../hosts + "/${host}/ssh_host_ed25519_key.pub")
(../../hosts + "/${host}/ssh_host_rsa_key.pub") (../../hosts + "/${host}/ssh_host_rsa_key.pub")
]; ];
# NOLINT(let_order) # NOLINT(let_order)
managedTargets = lib.genAttrs (workstationNames ++ serverNames) (name: { managedTargets = lib.genAttrs (workstationNames ++ serverNames) (name: {
hostName = registry.address.${name}.self; hostName = registry.address.${name}.self;
clientKey = clientKeyFor name; clientKey = clientKeyFor name;
hostKeys = hostKeysFor name; hostKeys = hostKeysFor name;
}); });
extraTargets = { extraTargets = {
# TODO: Pin Gitea's host key after migrating it from Proxmox. # TODO: Pin Gitea's host key after migrating it from Proxmox.
gitea = { gitea = {
@@ -44,6 +47,7 @@ let
]; ];
}; };
}; };
# NOLINT(let_order) # NOLINT(let_order)
mkTarget = name: target: { mkTarget = name: target: {
hostName = target.hostName or name; hostName = target.hostName or name;
@@ -60,6 +64,7 @@ let
defaultAuthorizedKeys = lib.flatten ( defaultAuthorizedKeys = lib.flatten (
clientKeysFor workstationNames ++ lib.optional isServer (clientKeysFor serverNames) clientKeysFor workstationNames ++ lib.optional isServer (clientKeysFor serverNames)
); );
outboundTargetNames = # NOLINT(let_order) outboundTargetNames = # NOLINT(let_order)
let let
groupTargets = groupTargets =
@@ -93,6 +98,7 @@ let
names = lib.unique (target.aliases ++ [ target.hostName ]); names = lib.unique (target.aliases ++ [ target.hostName ]);
in in
map withPort names; map withPort names;
keyWithoutComment = key: lib.concatStringsSep " " (lib.take 2 (lib.splitString " " key)); keyWithoutComment = key: lib.concatStringsSep " " (lib.take 2 (lib.splitString " " key));
sshSettingsFor = sshSettingsFor =