wireguard/home: Add basic overview page

It is very basic and not pretty, but it is a base that can be extended.
This commit is contained in:
Simon Bruder 2023-04-07 13:47:40 +02:00
parent ea232b1f58
commit 642d97cb52
Signed by: simon
GPG key ID: 8D3C82F9F309F8EC
3 changed files with 71 additions and 1 deletions

View file

@ -1,4 +1,4 @@
{ lib, config, pkgs, ... }: { lib, config, machines, pkgs, ... }:
let let
serverHostName = "vueko"; serverHostName = "vueko";
peers = { peers = {
@ -113,8 +113,46 @@ in
$TTL 3600 $TTL 3600
@ IN SOA ${serverHostName}.sbruder.de. hostmaster.sbruder.de. ${toString serial} 28800 3600 604800 3600 @ IN SOA ${serverHostName}.sbruder.de. hostmaster.sbruder.de. ${toString serial} 28800 3600 604800 3600
@ IN NS ${serverHostName}.sbruder.de. @ IN NS ${serverHostName}.sbruder.de.
@ IN A ${peers.${serverHostName}.address}
'' + peerRecords); '' + 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
'';
};
};
};
}; };
} }

View file

@ -0,0 +1,22 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>VPN</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<h1>VPN</h1>
<h2>Machines</h2>
{%- for machine, config in machines.items() %}
{%- set base_url = "http://" ~ machine ~ ".vpn.sbruder.de" %}
<h3>{{ machine }}</h3>
<ul>
{% if config.syncthing is not none %}<li><a href="{{ base_url }}:{{ config.syncthing }}/">Syncthing</a></li>{% endif %}
</ul>
{%- endfor %}
</div>
</body>
</html>

View file

@ -0,0 +1,10 @@
body {
font-family: "PT Sans", "Helvetica", "Helvetica Neue", "Roboto", "Arimo", "Arial", sans-serif;
margin: 0px;
}
.container {
max-width: 500px;
margin: 0 auto;
padding: 0 1rem;
}