File tree Expand file tree Collapse file tree 5 files changed +58
-9
lines changed
platforms/nixos/modules/lab/profiles/vpn Expand file tree Collapse file tree 5 files changed +58
-9
lines changed Original file line number Diff line number Diff line change 36
36
inherit ( nixpkgs-unstable ) lib ;
37
37
inherit ( import ./lib flake-inputs ) defineHost deviceProfiles makeImage ;
38
38
39
+ domain = "selfhosted.city" ;
40
+ datacenter = "nova" ;
41
+
39
42
# A subset of Hydra's standard architectures.
40
43
standardSystems = [
41
44
"x86_64-linux"
130
133
131
134
colmena = ( lib . mapAttrs defineHost hosts ) // rec {
132
135
defaults . lab = {
133
- domain = "selfhosted.city" ;
134
- datacenter = "nova" ;
136
+ inherit datacenter domain ;
135
137
136
138
networks = {
137
139
datacenter . ipv4 = {
260
262
}
261
263
] ;
262
264
} ;
265
+
266
+ vpn = {
267
+ about = "Manage the VPN." ;
268
+ subcommands . register = {
269
+ about = "Register a node on the VPN." ;
270
+ args = [
271
+ {
272
+ id = "host" ;
273
+ about = "Host to initialize." ;
274
+ required = true ;
275
+ }
276
+ {
277
+ id = "server_url" ;
278
+ about = "URL of the VPN server." ;
279
+ short = "s" ;
280
+ long = "server-url" ;
281
+ default_value = "http://rpi4-003.host.${ datacenter } .${ domain } :8080" ;
282
+ }
283
+ ] ;
284
+
285
+ # TODO: Use Colmena's deploy key commands instead and
286
+ # defer the oneshot setup by the key service.
287
+ run = pkgs . unstable . writers . writeNu "bootstrap-vpn-client.nu" ''
288
+ use std/log
289
+
290
+ let server_host = $env.server_url | url parse | get host
291
+ let response = ssh $server_host headscale preauthkey create --user dc-${ datacenter } --output json | from json
292
+ log info $"Auth key created id=($response.id)"
293
+
294
+ ssh $env.host tailscale up --login-server $env.server_url --auth-key $response.key
295
+ log info "VPN client ready"
296
+ '' ;
297
+ } ;
298
+ } ;
263
299
} ;
264
300
} ;
265
301
} )
Original file line number Diff line number Diff line change 1
1
{
2
+ lab . profiles = {
3
+ vpn . client . enable = true ;
4
+ } ;
5
+
2
6
home-manager . users . root . home . stateVersion = "23.11" ;
3
7
system . stateVersion = "23.05" ;
4
8
}
Original file line number Diff line number Diff line change 1
1
{
2
- # File server is temporarily disabled. 2/3 drives corrupted.
3
- # I'm a terrible sysadmin.
4
- lab . profiles . file-server . enable = false ;
2
+ lab . profiles = {
3
+ vpn . client . enable = true ;
4
+
5
+ # File server is temporarily disabled. 2/3 drives corrupted.
6
+ # I'm a terrible sysadmin.
7
+ file-server . enable = false ;
8
+ } ;
9
+
5
10
networking . hostId = "e3cda066" ; # Required by ZFS
6
11
7
12
home-manager . users . root . home . stateVersion = "23.11" ;
Original file line number Diff line number Diff line change 5
5
inherit ( config . lab . services . gateway ) wan ;
6
6
in
7
7
{
8
- lab . profiles . router . enable = true ;
8
+ lab . profiles = {
9
+ router . enable = true ;
10
+ vpn . client . enable = true ;
11
+ } ;
9
12
10
13
# Assign sensible names to the network interfaces. Anything with vlans needs
11
14
# a hardware-related filter to avoid conflicts with virtual devices.
Original file line number Diff line number Diff line change 19
19
} ;
20
20
21
21
config = lib . mkIf cfg . enable {
22
+ networking . firewall . allowedTCPPorts = [ port ] ;
23
+
22
24
services . headscale = {
23
25
enable = true ;
24
26
settings = {
25
27
server_url = "http://${ config . networking . hostName } .host.${ datacenter } .${ domain } :${ toString port } " ;
26
28
listen_addr = "0.0.0.0:${ toString port } " ;
27
- dns . base_domain = "vpn.${ datacenter } .${ domain } " ;
29
+ dns . base_domain = "${ datacenter } .vpn.${ domain } " ;
30
+ logtail . enabled = true ;
28
31
29
32
# TODO: Define ACLs.
30
33
} ;
31
34
} ;
32
-
33
- networking . firewall . allowedTCPPorts = [ port ] ;
34
35
} ;
35
36
}
You can’t perform that action at this time.
0 commit comments