Extract vpn exit node config to module
All checks were successful
CI / build (push) Successful in 2m49s
All checks were successful
CI / build (push) Successful in 2m49s
This commit is contained in:
parent
aaebb4bc19
commit
c5d9d01f84
4 changed files with 52 additions and 38 deletions
|
@ -78,22 +78,5 @@ in
|
|||
qois.backplane-net.enable = true;
|
||||
|
||||
# Configure this node to be used as an vpn exit node
|
||||
qois.backup-client.includePaths = [ "/var/lib/tailscale" ];
|
||||
services.tailscale = {
|
||||
enable = true;
|
||||
openFirewall = true;
|
||||
useRoutingFeatures = "server";
|
||||
authKeyFile = config.sops.secrets."tailscale/key".path;
|
||||
extraUpFlags = [
|
||||
"--timeout 60s"
|
||||
"--accept-dns=false"
|
||||
"--login-server=https://vpn.qo.is"
|
||||
"--advertise-exit-node"
|
||||
(
|
||||
with meta.network.virtual.backplane.v4; "--advertise-routes=${id}/${builtins.toString prefixLength}"
|
||||
)
|
||||
"--advertise-tags=tag:srv"
|
||||
];
|
||||
};
|
||||
|
||||
qois.vpn-exit-node.enable = true;
|
||||
}
|
||||
|
|
|
@ -3,8 +3,5 @@
|
|||
sops.secrets = {
|
||||
"system/hdd" = { };
|
||||
"system/initrd-ssh-key" = { };
|
||||
"tailscale/key" = {
|
||||
restartUnits = [ "tailscaled.service" ];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ in
|
|||
in
|
||||
{
|
||||
enable = true;
|
||||
resolveLocalQueries = false;
|
||||
resolveLocalQueries = true;
|
||||
settings = {
|
||||
interface = "vms-nat";
|
||||
bind-interfaces = true;
|
||||
|
@ -74,20 +74,5 @@ in
|
|||
|
||||
qois.backplane-net.enable = true;
|
||||
|
||||
# Use this node as vpn exit node
|
||||
qois.backup-client.includePaths = [ "/var/lib/tailscale" ];
|
||||
services.tailscale = {
|
||||
enable = true;
|
||||
openFirewall = true;
|
||||
useRoutingFeatures = "server";
|
||||
authKeyFile = config.sops.secrets."tailscale/key".path;
|
||||
extraUpFlags = [
|
||||
"--login-server=https://vpn.qo.is"
|
||||
"--advertise-exit-node"
|
||||
(
|
||||
with meta.network.virtual.backplane.v4; "--advertise-routes=${id}/${builtins.toString prefixLength}"
|
||||
)
|
||||
"--advertise-tags=tag:srv"
|
||||
];
|
||||
};
|
||||
qois.vpn-exit-node.enable = true;
|
||||
}
|
||||
|
|
49
nixos-modules/qois/vpn-exit-node/default.nix
Normal file
49
nixos-modules/qois/vpn-exit-node/default.nix
Normal file
|
@ -0,0 +1,49 @@
|
|||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.qois.vpn-exit-node;
|
||||
in
|
||||
{
|
||||
|
||||
options.qois.vpn-exit-node = {
|
||||
enable = mkEnableOption "vpn exit node";
|
||||
domain = mkOption {
|
||||
description = "Domain for the VPN admin server";
|
||||
type = types.str;
|
||||
default = "vpn.qo.is";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
|
||||
qois.backup-client.includePaths = [ "/var/lib/tailscale" ];
|
||||
|
||||
sops.secrets."tailscale/key".restartUnits = [ "tailscaled.service" ];
|
||||
|
||||
services.tailscale = {
|
||||
enable = true;
|
||||
openFirewall = true;
|
||||
useRoutingFeatures = "server";
|
||||
authKeyFile = config.sops.secrets."tailscale/key".path;
|
||||
extraUpFlags =
|
||||
let
|
||||
backplaneRoute =
|
||||
with config.qois.meta.network.virtual.backplane.v4;
|
||||
"${id}/${builtins.toString prefixLength}";
|
||||
in
|
||||
[
|
||||
"--timeout 60s"
|
||||
"--accept-dns=false"
|
||||
"--login-server=https://${cfg.domain}"
|
||||
"--advertise-exit-node"
|
||||
"--advertise-routes=${backplaneRoute}"
|
||||
"--advertise-tags=tag:srv"
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue