Hosts file for VPN

This commit is contained in:
Andrea Ciceri 2023-04-01 19:27:51 +02:00
parent e68e1fe843
commit 3008a49eee
Signed by: aciceri
SSH key fingerprint: SHA256:/AagBweyV4Hlfg9u092n8hbHwD5fcB6A3qhDiDA65Rg
2 changed files with 13 additions and 2 deletions

View file

@ -8,11 +8,12 @@
options.fleet = {
hosts = lib.mkOption {
description = "Host configuration";
type = lib.types.attrsOf (lib.types.submodule {
type = lib.types.attrsOf (lib.types.submodule ({name, ...}: {
options = {
name = lib.mkOption {
description = "Host name";
type = lib.types.strMatching "^$|^[[:alnum:]]([[:alnum:]_-]{0,61}[[:alnum:]])?$";
default = name;
};
system = lib.mkOption {
description = "NixOS architecture (a.k.a. system)";
@ -75,7 +76,7 @@
default = "ccr";
};
};
});
}));
default = {};
};
_mkNixosConfiguration = lib.mkOption {
@ -90,6 +91,12 @@
({lib, ...}: {
networking.hostName = lib.mkForce hostname;
nixpkgs.overlays = config.overlays;
networking.hosts =
lib.mapAttrs' (hostname: ip: {
name = ip;
value = ["${hostname}.fleet"];
})
(import "${self}/lib").ips;
})
"${self.outPath}/hosts/${hostname}"
]

View file

@ -9,4 +9,8 @@
mothership = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFlepPWHE9GvQIBcAQBQPd80oiePSPxGDnMdqpdEqx6I";
};
};
ips = {
mothership = "10.100.0.1";
thinkpad = "10.100.0.2";
};
}