Skip to content

Commit

Permalink
snixembed: add module
Browse files Browse the repository at this point in the history
https://git.sr.ht/~steef/snixembed

This is used by SafeEyes (another home-manager) module to show a
systemtray icon.

This fixes issue nix-community#5728.
  • Loading branch information
DamienCassou committed Oct 9, 2024
1 parent 0386303 commit 2677b20
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 0 deletions.
12 changes: 12 additions & 0 deletions modules/misc/news.nix
Original file line number Diff line number Diff line change
Expand Up @@ -1748,6 +1748,18 @@ in {
add `-w` to your assignment of `services.swayidle.extraArgs`.
'';
}

{
time = "2024-10-09T06:16:23+00:00";
condition = hostPlatform.isLinux;
message = ''
A new module is available: 'services.snixembed'.
snixembed proxies StatusNotifierItems as XEmbedded systemtray-spec
icons. This is useful for some tools in some environments, e.g., Safe
Eyes in i3, lxde or mate.
'';
}
];
};
}
1 change: 1 addition & 0 deletions modules/modules.nix
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ let
./services/screen-locker.nix
./services/sctd.nix
./services/signaturepdf.nix
./services/snixembed.nix
./services/spotifyd.nix
./services/ssh-agent.nix
./services/stalonetray.nix
Expand Down
50 changes: 50 additions & 0 deletions modules/services/snixembed.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{ config, lib, pkgs, ... }:

with lib;

let cfg = config.services.snixembed;
in {
meta.maintainers = [ hm.maintainers.DamienCassou ];

options = {
services.snixembed = {
enable = mkEnableOption
"snixembed: proxy StatusNotifierItems as XEmbedded systemtray-spec icons";

package = mkPackageOption pkgs "snixembed" { };

beforeUnits = mkOption {
type = with types; listOf str;
default = [ ];
example = [ "safeeyes.service" ];
description = ''
List of other units that should be started after snixembed.
'';
};
};
};

config = mkIf cfg.enable {
assertions = [
(hm.assertions.assertPlatform "services.snixembed" pkgs platforms.linux)
];

systemd.user.services.snixembed = {
Install.WantedBy = [ "graphical-session.target" ];

Unit = {
Description = "snixembed";
PartOf = [ "graphical-session.target" ];
StartLimitIntervalSec = 100;
StartLimitBurst = 10;
Before = cfg.beforeUnits;
};

Service = {
ExecStart = getExe pkgs.snixembed;
Restart = "on-failure";
RestartSec = 3;
};
};
};
}
1 change: 1 addition & 0 deletions tests/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ in import nmtSrc {
./modules/services/remmina
./modules/services/screen-locker
./modules/services/signaturepdf
./modules/services/snixembed
./modules/services/swayidle
./modules/services/swaync
./modules/services/swayosd
Expand Down
7 changes: 7 additions & 0 deletions tests/modules/services/snixembed/basic-configuration.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[Desktop Entry]
Exec=@xdg-utils@/bin/xdg-open http://localhost:9494
Icon=/snixembed/share/snixembed/public/favicon.ico
Name=Snixembed
Terminal=false
Type=Application
Version=1.4
16 changes: 16 additions & 0 deletions tests/modules/services/snixembed/basic-configuration.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{ ... }:

{
services.snixembed = {
enable = true;
beforeUnits = [ "safeeyes.service" ];
};

test.stubs = { snixembed = { outPath = "/snixembed"; }; };

nmt.script = ''
assertFileContent \
home-files/.config/systemd/user/snixembed.service \
${./basic-configuration.service}
'';
}
14 changes: 14 additions & 0 deletions tests/modules/services/snixembed/basic-configuration.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[Install]
WantedBy=graphical-session.target

[Service]
ExecStart=/snixembed/bin/dummy
Restart=on-failure
RestartSec=3

[Unit]
Before=safeeyes.service
Description=snixembed
PartOf=graphical-session.target
StartLimitBurst=10
StartLimitIntervalSec=100
1 change: 1 addition & 0 deletions tests/modules/services/snixembed/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ snixembed-basic-configuration = ./basic-configuration.nix; }

0 comments on commit 2677b20

Please sign in to comment.