nixos-config/terranix/tinc-test/01-terranix/config/file-generation.nix

31 lines
921 B
Nix
Raw Normal View History

2020-01-06 06:37:25 +01:00
# --------------------------------------------------------------------------------
#
# collect all server information and generate files which get picked up
# by 02-build to deploy the machines properly.
#
# This makes it possible to deploy VPNs like tinc and wireguard.
#
# --------------------------------------------------------------------------------
{ config, lib, pkgs, ... }: {
resource.local_file = {
nixosMachines = {
content = with lib;
let
serverPart = name: ''
${name} = {
host = "''${ hcloud_server.${name}.ipv4_address }";
user = "root";
};
'';
allServerParts = map serverPart (attrNames config.hcloud.server);
in ''
{
${concatStringsSep "\n" allServerParts}
}
'';
filename = "${toString ../../02-build/generated/nixos-machines.nix}";
};
};
}