summaryrefslogtreecommitdiff
path: root/modules/nixos/mixins/tailscale.nix
diff options
context:
space:
mode:
authorSeth Flynn <[email protected]>2025-02-13 16:54:19 -0500
committerSeth Flynn <[email protected]>2025-02-13 22:09:11 -0500
commit386ecf3d14ea486aba523b14200fcd2e7e04b9d6 (patch)
treec9009fe26ece76f0c9d76ba89895094ee500b054 /modules/nixos/mixins/tailscale.nix
parentfdd2dd359c1d72b9ebeb676efb4141b5536f160c (diff)
nixos: make more "traits" mixins
Diffstat (limited to 'modules/nixos/mixins/tailscale.nix')
-rw-r--r--modules/nixos/mixins/tailscale.nix34
1 files changed, 34 insertions, 0 deletions
diff --git a/modules/nixos/mixins/tailscale.nix b/modules/nixos/mixins/tailscale.nix
new file mode 100644
index 0000000..177aa90
--- /dev/null
+++ b/modules/nixos/mixins/tailscale.nix
@@ -0,0 +1,34 @@
+{
+ config,
+ lib,
+ ...
+}:
+
+let
+ cfg = config.services.tailscale;
+
+ usingTailscaleSSH = lib.elem "--ssh" config.services.tailscale.extraUpFlags;
+in
+
+{
+ config = lib.mkMerge [
+ {
+ services.tailscale = {
+ openFirewall = true;
+ };
+ }
+
+ (lib.mkIf cfg.enable {
+ networking.firewall = {
+ # Trust all connections over Tailscale
+ trustedInterfaces = [ config.services.tailscale.interfaceName ];
+ };
+ })
+
+ (lib.mkIf (cfg.enable && usingTailscaleSSH) {
+ networking.firewall = {
+ allowedTCPPorts = [ 22 ];
+ };
+ })
+ ];
+}