1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-09-21 13:57:31 +02:00

pasystray: add extraOptions

Allows a user to, for example, add the `-g` option.

Also add a basic test case.
This commit is contained in:
Motiejus Jakštys 2023-09-18 15:20:32 +03:00 committed by Mikilio
parent 84f11acf9a
commit b3f3f50f9e
No known key found for this signature in database
GPG key ID: 5B2F1A890CF33F3F
5 changed files with 51 additions and 4 deletions

View file

@ -2,14 +2,26 @@
with lib; with lib;
{ let cfg = config.services.pasystray;
in {
meta.maintainers = [ hm.maintainers.pltanton ]; meta.maintainers = [ hm.maintainers.pltanton ];
options = { options = {
services.pasystray = { enable = mkEnableOption "PulseAudio system tray"; }; services.pasystray = {
enable = mkEnableOption "PulseAudio system tray";
extraOptions = mkOption {
type = types.listOf types.str;
default = [ ];
description = ''
Extra command-line arguments to pass to {command}`pasystray`.
'';
};
};
}; };
config = mkIf config.services.pasystray.enable { config = mkIf cfg.enable {
assertions = [ assertions = [
(hm.assertions.assertPlatform "services.pasystray" pkgs platforms.linux) (hm.assertions.assertPlatform "services.pasystray" pkgs platforms.linux)
]; ];
@ -28,7 +40,8 @@ with lib;
Environment = Environment =
let toolPaths = makeBinPath [ pkgs.paprefs pkgs.pavucontrol ]; let toolPaths = makeBinPath [ pkgs.paprefs pkgs.pavucontrol ];
in [ "PATH=${toolPaths}" ]; in [ "PATH=${toolPaths}" ];
ExecStart = "${pkgs.pasystray}/bin/pasystray"; ExecStart = escapeShellArgs
([ "${pkgs.pasystray}/bin/pasystray" ] ++ cfg.extraOptions);
}; };
}; };
}; };

View file

@ -223,6 +223,7 @@ import nmt {
./modules/services/pantalaimon ./modules/services/pantalaimon
./modules/services/parcellite ./modules/services/parcellite
./modules/services/pass-secret-service ./modules/services/pass-secret-service
./modules/services/pasystray
./modules/services/pbgopy ./modules/services/pbgopy
./modules/services/picom ./modules/services/picom
./modules/services/playerctld ./modules/services/playerctld

View file

@ -0,0 +1 @@
{ pasystray-service = ./service.nix; }

View file

@ -0,0 +1,13 @@
[Install]
WantedBy=graphical-session.target
[Service]
Environment=PATH=@paprefs@/bin:@pavucontrol@/bin
ExecStart='@pasystray@/bin/pasystray' '-g'
[Unit]
After=graphical-session-pre.target
After=tray.target
Description=PulseAudio system tray
PartOf=graphical-session.target
Requires=tray.target

View file

@ -0,0 +1,19 @@
{ ... }:
{
services.pasystray = {
enable = true;
extraOptions = [ "-g" ];
};
test.stubs = {
pasystray = { };
paprefs = { };
pavucontrol = { };
};
nmt.script = ''
serviceFile=$(normalizeStorePaths home-files/.config/systemd/user/pasystray.service)
assertFileContent "$serviceFile" ${./expected.service}
'';
}