refactor(nixos): derive managed SSH targets
This commit is contained in:
@@ -12,7 +12,7 @@ let
|
||||
);
|
||||
clientKeysFor = names: lib.filter (key: key != null) (map (name: targets.${name}.clientKey) names);
|
||||
|
||||
targets = lib.mapAttrs mkTarget defaultTargets;
|
||||
targets = lib.mapAttrs mkTarget (managedTargets // extraTargets);
|
||||
mkTarget = name: target: {
|
||||
hostName = target.hostName or name;
|
||||
user = target.user or user;
|
||||
@@ -23,7 +23,26 @@ let
|
||||
};
|
||||
user = config.user.name;
|
||||
|
||||
defaultTargets = {
|
||||
managedTargets = lib.genAttrs managedHostNames (name: {
|
||||
hostName = registry.address.${name}.self;
|
||||
clientKey = clientKeyFor name;
|
||||
hostKeys = hostKeysFor name;
|
||||
});
|
||||
managedHostNames = workstationNames ++ serverNames;
|
||||
workstationNames = [
|
||||
"neogaia"
|
||||
"zeus"
|
||||
];
|
||||
serverNames = [ "pikachu" ];
|
||||
clientKeyFor = host: builtins.readFile (../../hosts + "/${host}/ssh_user_ed25519_key.pub");
|
||||
hostKeysFor =
|
||||
host:
|
||||
map builtins.readFile [
|
||||
(../../hosts + "/${host}/ssh_host_ed25519_key.pub")
|
||||
(../../hosts + "/${host}/ssh_host_rsa_key.pub")
|
||||
];
|
||||
|
||||
extraTargets = {
|
||||
# TODO: Pin Gitea's host key after migrating it from Proxmox.
|
||||
gitea = {
|
||||
hostName = "git.alexion.dev";
|
||||
@@ -34,38 +53,8 @@ let
|
||||
"git.alexion.dev"
|
||||
];
|
||||
};
|
||||
|
||||
neogaia = {
|
||||
hostName = registry.address.neogaia.self;
|
||||
clientKey = clientKeyFor "neogaia";
|
||||
hostKeys = hostKeysFor "neogaia";
|
||||
};
|
||||
|
||||
zeus = {
|
||||
hostName = registry.address.zeus.self;
|
||||
clientKey = clientKeyFor "zeus";
|
||||
hostKeys = hostKeysFor "zeus";
|
||||
};
|
||||
|
||||
pikachu = {
|
||||
hostName = registry.address.pikachu.self;
|
||||
clientKey = clientKeyFor "pikachu";
|
||||
hostKeys = hostKeysFor "pikachu";
|
||||
};
|
||||
};
|
||||
clientKeyFor = host: builtins.readFile (../../hosts + "/${host}/ssh_user_ed25519_key.pub");
|
||||
hostKeysFor =
|
||||
host:
|
||||
map builtins.readFile [
|
||||
(../../hosts + "/${host}/ssh_host_ed25519_key.pub")
|
||||
(../../hosts + "/${host}/ssh_host_rsa_key.pub")
|
||||
];
|
||||
workstationNames = [
|
||||
"neogaia"
|
||||
"zeus"
|
||||
];
|
||||
isServer = lib.elem config.networking.hostName serverNames;
|
||||
serverNames = [ "pikachu" ];
|
||||
|
||||
knownHosts = lib.listToAttrs (
|
||||
lib.concatLists (
|
||||
|
||||
Reference in New Issue
Block a user