blob: 22168f377ad55be22724dbc9e58c3355bc71e41f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
{
config,
lib,
secretsDir,
...
}: let
cfg = config.features.tailscale;
in {
options.features.tailscale = {
enable = lib.mkEnableOption "enable support for tailscale";
ssh.enable = lib.mkEnableOption "enable support for tailscale ssh";
};
config = lib.mkIf cfg.enable {
age.secrets = lib.mkIf cfg.ssh.enable {
tailscaleAuthKey.file = "${secretsDir}/tailscaleAuthKey.age";
};
networking.firewall =
{
trustedInterfaces = ["tailscale0"];
}
// lib.optionalAttrs cfg.ssh.enable {
allowedTCPPorts = [22];
};
services.tailscale =
{
enable = true;
openFirewall = true;
}
// lib.optionalAttrs cfg.ssh.enable {
authKeyFile = config.age.secrets.tailscaleAuthKey.path;
extraUpFlags = ["--ssh"];
};
};
}
|