From 4f9cbe4384e00cf2cf80e99741e93f12a67a8f32 Mon Sep 17 00:00:00 2001 From: Marien Zwart Date: Thu, 14 May 2026 20:35:00 +1000 Subject: [PATCH] tailscale-systray: make theme configurable --- modules/services/tailscale-systray.nix | 27 ++++++++++++++++++- .../services/tailscale-systray/default.nix | 1 + .../services/tailscale-systray/theme.nix | 19 +++++++++++++ 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 tests/modules/services/tailscale-systray/theme.nix diff --git a/modules/services/tailscale-systray.nix b/modules/services/tailscale-systray.nix index fa4207aff..19fd7ffa6 100644 --- a/modules/services/tailscale-systray.nix +++ b/modules/services/tailscale-systray.nix @@ -15,6 +15,20 @@ in enable = lib.mkEnableOption "Official Tailscale systray application for Linux"; package = lib.mkPackageOption pkgs "tailscale" { }; + + theme = lib.mkOption { + type = lib.types.nullOr ( + lib.types.enum [ + "dark" + "dark:nobg" + "light" + "light:nobg" + ] + ); + default = null; + example = "dark:nobg"; + description = "Color theme to use for the Tailscale icon."; + }; }; config = lib.mkIf cfg.enable { @@ -26,6 +40,12 @@ in Tailscale systray is available since version 1.88.1 ''; } + { + assertion = cfg.theme != null -> lib.versionAtLeast cfg.package.version "1.98"; + message = '' + Tailscale systray supports themes since version 1.98 + ''; + } ]; systemd.user.services.tailscale-systray = { @@ -41,7 +61,12 @@ in Install = { WantedBy = [ "graphical-session.target" ]; }; - Service.ExecStart = "${lib.getExe cfg.package} systray"; + Service.ExecStart = lib.concatStringsSep " " ( + [ + "${lib.getExe cfg.package} systray" + ] + ++ lib.optional (cfg.theme != null) "--theme ${cfg.theme}" + ); }; }; } diff --git a/tests/modules/services/tailscale-systray/default.nix b/tests/modules/services/tailscale-systray/default.nix index 0c5b66a70..6594c3a33 100644 --- a/tests/modules/services/tailscale-systray/default.nix +++ b/tests/modules/services/tailscale-systray/default.nix @@ -2,4 +2,5 @@ lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux { tailscale-systray-basic = ./basic.nix; + tailscale-systray-theme = ./theme.nix; } diff --git a/tests/modules/services/tailscale-systray/theme.nix b/tests/modules/services/tailscale-systray/theme.nix new file mode 100644 index 000000000..8e0067f7f --- /dev/null +++ b/tests/modules/services/tailscale-systray/theme.nix @@ -0,0 +1,19 @@ +{ config, ... }: +{ + services.tailscale-systray = { + enable = true; + theme = "dark:nobg"; + package = config.lib.test.mkStubPackage { + name = "tailscale"; + version = "1.98.1"; + outPath = "@tailscale@"; + }; + }; + + nmt.script = '' + serviceFile=home-files/.config/systemd/user/tailscale-systray.service + assertFileExists $serviceFile + assertFileRegex $serviceFile \ + '^ExecStart=@tailscale@/bin/tailscale systray --theme dark:nobg$' + ''; +}