blob: 9eba42863570c8537280ee8c7773eb70f007c918 (
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 "Tailscale";
ssh.enable = lib.mkEnableOption "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"];
};
};
}
|