tailscale-systray: make theme configurable

This commit is contained in:
Marien Zwart
2026-05-14 20:35:00 +10:00
committed by Matthieu Coudron
parent f04b141d1a
commit 4f9cbe4384
3 changed files with 46 additions and 1 deletions

View File

@@ -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}"
);
};
};
}

View File

@@ -2,4 +2,5 @@
lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux {
tailscale-systray-basic = ./basic.nix;
tailscale-systray-theme = ./theme.nix;
}

View File

@@ -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$'
'';
}