pasystray: add extraOptions
Allows a user to, for example, add the `-g` option.
Also add a basic test case.
(cherry picked from commit 8045eb45a7
)
This commit is contained in:
parent
1f5735f335
commit
07682fff75
|
@ -2,14 +2,26 @@
|
|||
|
||||
with lib;
|
||||
|
||||
{
|
||||
let cfg = config.services.pasystray;
|
||||
|
||||
in {
|
||||
meta.maintainers = [ hm.maintainers.pltanton ];
|
||||
|
||||
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 = [
|
||||
(hm.assertions.assertPlatform "services.pasystray" pkgs platforms.linux)
|
||||
];
|
||||
|
@ -28,7 +40,8 @@ with lib;
|
|||
Environment =
|
||||
let toolPaths = makeBinPath [ pkgs.paprefs pkgs.pavucontrol ];
|
||||
in [ "PATH=${toolPaths}" ];
|
||||
ExecStart = "${pkgs.pasystray}/bin/pasystray";
|
||||
ExecStart = escapeShellArgs
|
||||
([ "${pkgs.pasystray}/bin/pasystray" ] ++ cfg.extraOptions);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -203,6 +203,7 @@ import nmt {
|
|||
./modules/services/pantalaimon
|
||||
./modules/services/parcellite
|
||||
./modules/services/pass-secret-service
|
||||
./modules/services/pasystray
|
||||
./modules/services/pbgopy
|
||||
./modules/services/picom
|
||||
./modules/services/playerctld
|
||||
|
|
1
tests/modules/services/pasystray/default.nix
Normal file
1
tests/modules/services/pasystray/default.nix
Normal file
|
@ -0,0 +1 @@
|
|||
{ pasystray-service = ./service.nix; }
|
13
tests/modules/services/pasystray/expected.service
Normal file
13
tests/modules/services/pasystray/expected.service
Normal 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
|
19
tests/modules/services/pasystray/service.nix
Normal file
19
tests/modules/services/pasystray/service.nix
Normal 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}
|
||||
'';
|
||||
}
|
Loading…
Reference in a new issue