kartei tv: move around hostFiles & co.

This commit is contained in:
tv 2022-12-29 17:33:07 +01:00
parent cda9bcfaff
commit 9cb022698e

View File

@ -1,47 +1,5 @@
with import ../../lib; with import ../../lib;
{ config, ... }: let { config, ... }: {
evalHost = hostName: hostConfig: evalSubmodule types.host [
hostConfig
{
name = hostName;
owner = config.krebs.users.tv;
}
(optionalAttrs (hasAttrByPath ["nets" "retiolum"] hostConfig) {
nets.retiolum = {
ip6.addr =
(krebs.genipv6 "retiolum" "tv" { inherit hostName; }).address;
};
})
(let
pubkey-path = ./wiregrill + "/${hostName}.pub";
in optionalAttrs (pathExists pubkey-path) {
nets.wiregrill = {
aliases = [
"${hostName}.w"
];
ip6.addr =
(krebs.genipv6 "wiregrill" "tv" { inherit hostName; }).address;
wireguard.pubkey = readFile pubkey-path;
};
})
(host: mkIf (host.config.ssh.pubkey != null) {
ssh.privkey = mapAttrs (const mkDefault) {
path = config.krebs.secret.file "ssh.id_${host.config.ssh.privkey.type}";
type = head (toList (match "ssh-([^ ]+) .*" host.config.ssh.pubkey));
};
})
];
hostFiles =
mapAttrs'
(name: type: {
name = removeSuffix ".nix" name;
value = ./hosts + "/${name}";
})
(readDir ./hosts);
in {
dns.providers = { dns.providers = {
"viljetic.de" = "regfish"; "viljetic.de" = "regfish";
}; };
@ -53,9 +11,43 @@ in {
lambda = hostSource { inherit config lib; }; lambda = hostSource { inherit config lib; };
set = hostSource; set = hostSource;
}; };
in in evalSubmodule types.host [
evalHost hostName hostConfig) hostConfig
hostFiles; {
name = hostName;
owner = config.krebs.users.tv;
}
(optionalAttrs (hasAttrByPath ["nets" "retiolum"] hostConfig) {
nets.retiolum = {
ip6.addr =
(krebs.genipv6 "retiolum" "tv" { inherit hostName; }).address;
};
})
(let
pubkey-path = ./wiregrill + "/${hostName}.pub";
in optionalAttrs (pathExists pubkey-path) {
nets.wiregrill = {
aliases = [
"${hostName}.w"
];
ip6.addr =
(krebs.genipv6 "wiregrill" "tv" { inherit hostName; }).address;
wireguard.pubkey = readFile pubkey-path;
};
})
(host: mkIf (host.config.ssh.pubkey != null) {
ssh.privkey = mapAttrs (const mkDefault) {
path = config.krebs.secret.file "ssh.id_${host.config.ssh.privkey.type}";
type = head (toList (match "ssh-([^ ]+) .*" host.config.ssh.pubkey));
};
})
])
(mapAttrs'
(name: type: {
name = removeSuffix ".nix" name;
value = ./hosts + "/${name}";
})
(readDir ./hosts));
sitemap = { sitemap = {
"http://cgit.krebsco.de" = { "http://cgit.krebsco.de" = {
desc = "Git repositories"; desc = "Git repositories";