summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorDomen Kožar <domen@dev.si>2022-09-18 10:08:04 +0100
committerGitHub <noreply@github.com>2022-09-18 10:08:04 +0100
commit127acf9c3ff5edcd5df3ff83b2017b7713c3d362 (patch)
tree9ebf4b99b7be5e268775b65b9c4295d9fcecb758 /modules
parent3b69bf3cc26ae19de847bfe54d6ab22d7381a90a (diff)
parent7698ffce98b0535de3f1de25a7a3ab1249eef46e (diff)
Merge pull request #524 from sellout/tailscale
Add tailscale service module
Diffstat (limited to 'modules')
-rw-r--r--modules/module-list.nix1
-rw-r--r--modules/services/tailscale.nix55
2 files changed, 56 insertions, 0 deletions
diff --git a/modules/module-list.nix b/modules/module-list.nix
index b56ba67..7e771b3 100644
--- a/modules/module-list.nix
+++ b/modules/module-list.nix
@@ -65,6 +65,7 @@
./services/spotifyd.nix
./services/synapse-bt.nix
./services/synergy
+ ./services/tailscale.nix
./services/yabai
./services/nextdns
./programs/bash
diff --git a/modules/services/tailscale.nix b/modules/services/tailscale.nix
new file mode 100644
index 0000000..fb63af9
--- /dev/null
+++ b/modules/services/tailscale.nix
@@ -0,0 +1,55 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+let
+ cfg = config.services.tailscale;
+
+in
+{
+ options.services.tailscale = {
+ domain = mkOption {
+ type = types.str;
+ default = "";
+ description = "The Tailscale domain. This is displayed at the top left of https://login.tailscale.com/admin, next to the Tailscale logo.";
+ };
+
+ enable = mkEnableOption "Tailscale client daemon";
+
+ package = mkOption {
+ type = types.package;
+ default = pkgs.tailscale;
+ defaultText = literalExpression "pkgs.tailscale";
+ description = "The package to use for tailscale";
+ };
+
+ magicDNS = {
+ enable = mkEnableOption "Whether to configure networking to work with Tailscale's MagicDNS.";
+ };
+ };
+
+ config = mkIf cfg.enable {
+ warnings = [
+ (mkIf (cfg.magicDNS.enable && cfg.domain == "") "${showOption cfg.domain} isn't empty, Tailscale MagicDNS search path won't be configured.")
+ ];
+
+ environment.systemPackages = [ cfg.package ];
+ launchd.user.agents.tailscaled = {
+ # derived from
+ # https://github.com/tailscale/tailscale/blob/main/cmd/tailscaled/install_darwin.go#L30
+ serviceConfig = {
+ Label = "com.tailscale.tailscaled";
+ ProgramArguments = [ "${lib.getBin cfg.package}/bin/tailscaled" ];
+ RunAtLoad = true;
+ };
+ };
+ networking = mkIf cfg.magicDNS.enable {
+ dns = [ "100.100.100.100" ];
+ search =
+ if cfg.domain == "" then
+ [ ]
+ else
+ [ "${cfg.domain}.beta.tailscale.net" ];
+ };
+ };
+}