diff --git a/modules/wireguard/home.nix b/modules/wireguard/home.nix index 35aed52..f3920cf 100644 --- a/modules/wireguard/home.nix +++ b/modules/wireguard/home.nix @@ -1,4 +1,4 @@ -{ lib, config, pkgs, ... }: +{ lib, config, machines, pkgs, ... }: let serverHostName = "vueko"; peers = { @@ -113,8 +113,46 @@ in $TTL 3600 @ IN SOA ${serverHostName}.sbruder.de. hostmaster.sbruder.de. ${toString serial} 28800 3600 604800 3600 @ IN NS ${serverHostName}.sbruder.de. + @ IN A ${peers.${serverHostName}.address} '' + peerRecords); }; }; + + services.nginx = lib.mkIf enableServer { + virtualHosts."vpn.sbruder.de" = { + root = + let + templateData = { + machines = lib.mapAttrs + (machine: { config, ... }: { + syncthing = if config.services.syncthing.enable then 8384 else null; + }) + machines; + }; + in + pkgs.stdenv.mkDerivation { + name = "vpn-home"; + + src = ./home; + + nativeBuildInputs = with pkgs; [ j2cli ]; + + buildPhase = '' + runHook preBuild + j2 -f json -o index.html index.html.j2 - << EOF + ${builtins.toJSON templateData} + EOF + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + install -D index.html $out/index.html + install -D style.css $out/style.css + runHook postInstall + ''; + }; + }; + }; }; } diff --git a/modules/wireguard/home/index.html.j2 b/modules/wireguard/home/index.html.j2 new file mode 100644 index 0000000..fdab2ee --- /dev/null +++ b/modules/wireguard/home/index.html.j2 @@ -0,0 +1,22 @@ + + +
+ + +