diff --git a/hosts/homex/configuration.nix b/hosts/homex/configuration.nix index 3441c11..6c38bef 100644 --- a/hosts/homex/configuration.nix +++ b/hosts/homex/configuration.nix @@ -23,6 +23,12 @@ ip = "100.66.139.89"; localIp = "192.168.1.10"; + tailscale = { + enable = true; + mode = "both"; + exitNode = true; + }; + forgejo = { enable = true; settings.users."user1" = { diff --git a/hosts/homex/network.nix b/hosts/homex/network.nix index 4b0f05b..57b1e0e 100644 --- a/hosts/homex/network.nix +++ b/hosts/homex/network.nix @@ -14,11 +14,6 @@ nameservers = [ "100.100.100.100" "1.1.1.1" "8.8.8.8" ]; }; - services.tailscale = { - enable = true; - useRoutingFeatures = "both"; - }; - boot.kernel.sysctl."net.ipv4.ip_forward" = 1; boot.kernel.sysctl."net.ipv6.conf.all.forwarding" = 1; diff --git a/modules/nixos/homelab/default.nix b/modules/nixos/homelab/default.nix index 03994ae..e35326b 100644 --- a/modules/nixos/homelab/default.nix +++ b/modules/nixos/homelab/default.nix @@ -26,6 +26,7 @@ in ./adguard.nix ./caddy.nix ./forgejo.nix + ./tailscale.nix ]; options.homelab = with lib; with lib.types; { enable = mkEnableOption ""; diff --git a/modules/nixos/homelab/tailscale.nix b/modules/nixos/homelab/tailscale.nix new file mode 100644 index 0000000..b03ff08 --- /dev/null +++ b/modules/nixos/homelab/tailscale.nix @@ -0,0 +1,33 @@ +{ config, lib, pkgs, ... }: + +let + cfg = config.homelab.tailscale; +in +{ + imports = [ + ./network.nix + ]; + options.homelab.tailscale = with lib; with lib.types; { + enable = mkEnableOption ""; + mode = mkOption { + type = enum [ + "client" + "server" + "both" + ]; + default = "both"; + }; + exitNode = mkOption { + type = bool; + default = false; + }; + settings = { }; + }; + config = lib.mkIf cfg.enable { + services.tailscale = { + enable = true; + useRoutingFeatures = cfg.mode; + }; + }; +} +