fix: add public hostname to ssh config and refactor

This commit is contained in:
2026-02-02 18:34:39 +01:00
parent 4236aa1def
commit c538c5ad08
4 changed files with 35 additions and 34 deletions

View File

@@ -3,6 +3,16 @@
inputs,
}:
let
mkNode = hostname: tags: {
imports = [ ../hosts/${hostname} ];
deployment = {
targetHost = self.nixosConfigurations.${hostname}.config.ssh.publicHostname;
targetUser = self.nixosConfigurations.${hostname}.config.ssh.username;
inherit tags;
};
};
in
inputs.colmena.lib.makeHive {
meta = {
nixpkgs = import inputs.nixpkgs {
@@ -13,35 +23,9 @@ inputs.colmena.lib.makeHive {
nodeSpecialArgs = builtins.mapAttrs (_: v: v._module.specialArgs or { }) self.nixosConfigurations;
};
astyanax = {
imports = [ ../hosts/astyanax ];
deployment.tags = [ "local" ];
};
andromache = {
imports = [ ../hosts/andromache ];
deployment.tags = [ "local" ];
};
vm = {
imports = [ ../hosts/vm ];
deployment.tags = [ "local" ];
};
hecuba = {
imports = [ ../hosts/hecuba ];
deployment = {
targetHost = "server.hektormisplon.xyz";
targetUser = "username";
tags = [ "cloud" ];
};
};
eetion = {
imports = [ ../hosts/eetion ];
deployment = {
targetUser = "h";
tags = [ "arm" ];
};
};
astyanax = mkNode "astyanax" [ "local" ];
andromache = mkNode "andromache" [ "local" ];
vm = mkNode "vm" [ "local" ];
hecuba = mkNode "hecuba" [ "cloud" ];
eetion = mkNode "eetion" [ "arm" ];
}

View File

@@ -18,8 +18,20 @@ in
enable = true;
enableDefaultConfig = false;
matchBlocks = lib.genAttrs hostsWithKeys (hostname: {
matchBlocks = lib.genAttrs hostsWithKeys (
hostname:
let
hostConfig = outputs.nixosConfigurations.${hostname}.config;
publicHostname = hostConfig.ssh.publicHostname;
targetUser = hostConfig.ssh.username;
in
{
host = hostname;
});
user = targetUser;
}
// lib.optionalAttrs (publicHostname != "") {
hostname = publicHostname;
}
);
};
}

View File

@@ -24,6 +24,7 @@ in
networking.hostName = hostName;
ssh.username = username;
ssh.publicHostname = "server.hektormisplon.xyz";
ssh.authorizedHosts = [
"andromache"
"astyanax"

View File

@@ -9,6 +9,10 @@
type = lib.types.str;
default = "h";
};
publicHostname = lib.mkOption {
type = lib.types.str;
default = "";
};
};
# auto generate authorized_keys from `authorizedHosts`