From 4e619eb0c46452ed2f64e977b68e2f8150b44e4c Mon Sep 17 00:00:00 2001 From: Pim Kunis Date: Tue, 23 Jul 2024 22:50:11 +0200 Subject: [PATCH] feat(tailscale): Enable warwick as exit node and subnet router --- machines/warwick.nix | 7 +++++-- nixos-modules/networking/default.nix | 6 ++---- nixos-modules/tailscale.nix | 18 ++++++++++++++++-- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/machines/warwick.nix b/machines/warwick.nix index a53159c..f8c2af6 100644 --- a/machines/warwick.nix +++ b/machines/warwick.nix @@ -3,8 +3,11 @@ arch = "aarch64-linux"; isRaspberryPi = true; - nixosModule = { - lab.monitoring.server.enable = true; + nixosModule = { lib, ... }: { + lab = { + monitoring.server.enable = true; + tailscale.advertiseExitNode = true; + }; services.bird2 = { enable = false; diff --git a/nixos-modules/networking/default.nix b/nixos-modules/networking/default.nix index e07f8c5..df36440 100644 --- a/nixos-modules/networking/default.nix +++ b/nixos-modules/networking/default.nix @@ -2,12 +2,10 @@ config = { networking = { domain = "dmz"; - nftables.enable = true; + nftables.enable = lib.mkDefault true; useDHCP = false; - firewall = { - enable = true; - }; + firewall.enable = lib.mkDefault true; }; systemd.network = { diff --git a/nixos-modules/tailscale.nix b/nixos-modules/tailscale.nix index 0edd968..796e528 100644 --- a/nixos-modules/tailscale.nix +++ b/nixos-modules/tailscale.nix @@ -1,12 +1,26 @@ -{ config, ... }: { +{ lib, config, ... }: +let + cfg = config.lab.tailscale; +in +{ + options = { + lab.tailscale.advertiseExitNode = lib.mkOption { + type = lib.types.bool; + default = false; + }; + }; + config = { services.tailscale = { enable = true; authKeyFile = config.sops.secrets."tailscale/authKey".path; + useRoutingFeatures = "server"; + openFirewall = true; extraUpFlags = [ "--hostname=${config.networking.hostName}" - ]; + ] ++ lib.lists.optional cfg.advertiseExitNode "--advertise-exit-node" + ++ lib.lists.optional cfg.advertiseExitNode "--advertise-routes=192.168.30.0/24"; }; sops.secrets."tailscale/authKey" = { };