Skip to content

Commit 9b47220

Browse files
committed
feat: fix VPN configuration and disable sandboxing for VPS
1 parent c922c6a commit 9b47220

File tree

4 files changed

+33
-15
lines changed

4 files changed

+33
-15
lines changed

hosts/caenus/default.nix

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@
4646
## System-wide packages ##
4747
programs.nix-ld.enable = true;
4848

49+
# VPS with limited kernel permissions; disable sandboxing
50+
nix.settings.sandbox = false;
51+
4952
# https://wiki.nixos.org/wiki/FAQ/When_do_I_update_stateVersion
5053
system.stateVersion = "24.11";
5154
}

hosts/nexus/config/wireguard.nix

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,15 @@ let
1818

1919
# ── Dynamic VPN Client Discovery ──
2020
# Filter hosts that are VPN clients:
21-
# - Not this host (nexus)
22-
# - Has vpn config
23-
# - Has endpoint set (clients connect TO a server, servers don't have endpoint)
21+
# - Not this host (nexus - the server)
22+
# - Has vpn config with publicKey
23+
# - Has a /32 address (clients have /32, server has /24)
2424
vpnClients = lib.filterAttrs (
25-
name: spec: name != host.hostName && spec.vpn or null != null && spec.vpn.endpoint or null != null
25+
name: spec:
26+
name != host.hostName
27+
&& spec.vpn or null != null
28+
&& spec.vpn.publicKey or null != null
29+
&& lib.hasSuffix "/32" (spec.vpn.address or "")
2630
) hosts;
2731

2832
# Build peer config from host spec
@@ -51,6 +55,12 @@ in
5155
allowedUDPPorts = [ vpnPort ];
5256
# Trust the VPN interface - allow all traffic from VPN peers
5357
trustedInterfaces = [ vpnInterface ];
58+
# Allow rathole container (on pangolin bridge) to reach WireGuard
59+
# Docker NAT rules intercept local-destined traffic before the normal
60+
# firewall rules apply, so we need an explicit rule for br-pangolin
61+
extraInputRules = ''
62+
iifname "br-pangolin" udp dport ${toString vpnPort} accept
63+
'';
5464
};
5565
};
5666
}

mix/default.nix

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828
"video"
2929
"wheel"
3030
];
31-
32-
wgEndpoint = "pangolin.ryot.foo:51821";
3331
in
3432
{
3533
## Secrets ##
@@ -115,9 +113,12 @@
115113
user = "toph";
116114
ip = "10.2.2.4";
117115
desktop = {
118-
niri = {
116+
hyprland = {
119117
enable = true;
120118
default = true;
119+
};
120+
niri = {
121+
enable = true;
121122
dms = {
122123
includeBinds = true;
123124
includeColors = true;
@@ -139,9 +140,8 @@
139140
tank = true;
140141
};
141142
vpn = {
142-
publicKey = "ECl4YWWZfuAdYesxSUOSq7mTIYwII/eYg78dLR9XpmU=";
143+
publicKey = "A+pF7xjkh+TcI2w9CqZydF8oRSQQxNvPpGp18/R3YCE=";
143144
address = "10.10.0.4/32";
144-
endpoint = wgEndpoint;
145145
};
146146
};
147147

@@ -152,8 +152,10 @@
152152
hyprland = {
153153
enable = true;
154154
default = true;
155+
dms = {
156+
sourceOutputs = true;
157+
};
155158
};
156-
niri.enable = true;
157159
};
158160
greeter = {
159161
type = "dms";
@@ -184,7 +186,7 @@
184186
isMinimal = true;
185187
mounts.repo = true;
186188
vpn = {
187-
publicKey = "iOSuhmjJhUcqQQBnYOs/3WSs6dyX6JnqWzZ7JbceulU=";
189+
publicKey = "CsFrUwKp1EQoBJqKkn44/P8q2+Zm5U0YTEpkLlrKlzI=";
188190
address = "10.10.0.1/24"; # Server address
189191
# No endpoint - this is the VPN server
190192
};
@@ -215,7 +217,6 @@
215217
vpn = {
216218
publicKey = "9vgWTiGy9lwjXT6/hqxXNodw4jdhZPVRpbwTIWAxDWg=";
217219
address = "10.10.0.8/32";
218-
endpoint = wgEndpoint;
219220
};
220221
};
221222

@@ -224,7 +225,6 @@
224225
vpn = {
225226
publicKey = "n9EbRKf4syovfi3lnTJ7NCuywLh1IuHL7XX+wK3drUg=";
226227
address = "10.10.0.10/32";
227-
endpoint = wgEndpoint;
228228
};
229229
};
230230
};

modules/hosts/common/vpn.nix

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ let
2020
# Get private key for this host from secrets
2121
hostPrivateKey = secrets.service."wg-${host.hostName}".privateKey or "";
2222

23+
# Default endpoint: use secrets.service.caenus.ip (can be overridden per-host)
24+
caelusIp = secrets.service.caenus.ip;
25+
defaultEndpoint = "${caelusIp}:51821";
26+
endpoint = if cfgWg ? endpoint && cfgWg.endpoint != null then cfgWg.endpoint else defaultEndpoint;
27+
2328
# Allowed IP ranges for the VPN (semicolon-separated for NetworkManager)
2429
allowedIPs = lib.concatStringsSep ";" [
2530
"10.10.0.0/24" # VPN subnet (includes DNS at 10.10.0.1)
@@ -31,7 +36,7 @@ let
3136
];
3237
in
3338
{
34-
config = lib.mkIf (cfgWg != null && cfgWg.endpoint != null) {
39+
config = lib.mkIf (cfgWg != null) {
3540
assertions = [
3641
{
3742
assertion = nexusPublicKey != null;
@@ -58,7 +63,7 @@ in
5863

5964
# Peer config - section name includes the public key
6065
"wireguard-peer.${nexusPublicKey}" = {
61-
endpoint = cfgWg.endpoint;
66+
endpoint = endpoint;
6267
persistent-keepalive = "25";
6368
allowed-ips = allowedIPs;
6469
};

0 commit comments

Comments
 (0)