1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-27 05:29:46 +01:00

cliphist: support multiple systemdTargets properly

Using a space separated list of targets as a single string element in
the list doesn't work properly. Change property to support list of
targets and backwards compatibility with warning for single string.
This commit is contained in:
Austin Horstman 2024-07-24 22:39:23 -05:00
parent 9c1a1c7df4
commit 1891bc8b06
No known key found for this signature in database
4 changed files with 47 additions and 8 deletions

View file

@ -3,6 +3,14 @@ let cfg = config.services.cliphist;
in { in {
meta.maintainers = [ lib.hm.maintainers.janik ]; meta.maintainers = [ lib.hm.maintainers.janik ];
imports = [
(lib.mkRenamedOptionModule [ "services" "cliphist" "systemdTarget" ] [
"services"
"cliphist"
"systemdTargets"
])
];
options.services.cliphist = { options.services.cliphist = {
enable = enable =
lib.mkEnableOption "cliphist, a clipboard history manager for wayland"; lib.mkEnableOption "cliphist, a clipboard history manager for wayland";
@ -25,16 +33,18 @@ in {
''; '';
}; };
systemdTarget = lib.mkOption { systemdTargets = lib.mkOption {
type = lib.types.str; type = with lib.types; either (listOf str) str;
default = "graphical-session.target"; default = [ "graphical-session.target" ];
example = "sway-session.target"; example = "sway-session.target";
description = '' description = ''
The systemd target that will automatically start the cliphist service. The systemd targets that will automatically start the cliphist service.
When setting this value to `"sway-session.target"`, When setting this value to `["sway-session.target"]`,
make sure to also enable {option}`wayland.windowManager.sway.systemd.enable`, make sure to also enable {option}`wayland.windowManager.sway.systemd.enable`,
otherwise the service may never be started. otherwise the service may never be started.
Note: A single string value is deprecated, please use a list.
''; '';
}; };
}; };
@ -61,7 +71,7 @@ in {
Restart = "on-failure"; Restart = "on-failure";
}; };
Install = { WantedBy = [ cfg.systemdTarget ]; }; Install = { WantedBy = lib.toList cfg.systemdTargets; };
}; };
systemd.user.services.cliphist-images = lib.mkIf cfg.allowImages { systemd.user.services.cliphist-images = lib.mkIf cfg.allowImages {
@ -77,7 +87,7 @@ in {
Restart = "on-failure"; Restart = "on-failure";
}; };
Install = { WantedBy = [ cfg.systemdTarget ]; }; Install = { WantedBy = lib.toList cfg.systemdTargets; };
}; };
}; };
} }

View file

@ -0,0 +1,20 @@
{ ... }:
{
services.cliphist = {
enable = true;
systemdTargets = [ "sway-session.target" "hyprland-session.target" ];
};
test.stubs = {
cliphist = { };
wl-clipboard = { };
};
nmt.script = ''
assertFileExists home-files/.config/systemd/user/cliphist.service
assertFileExists home-files/.config/systemd/user/sway-session.target.wants/cliphist.service
assertFileExists home-files/.config/systemd/user/hyprland-session.target.wants/cliphist.service
'';
}

View file

@ -1,4 +1,4 @@
{ ... }: { lib, options, ... }:
{ {
services.cliphist = { services.cliphist = {
@ -13,5 +13,13 @@
nmt.script = '' nmt.script = ''
assertFileExists home-files/.config/systemd/user/cliphist.service assertFileExists home-files/.config/systemd/user/cliphist.service
assertFileExists home-files/.config/systemd/user/sway-session.target.wants/cliphist.service
''; '';
test.asserts.warnings.expected = [
"The option `services.cliphist.systemdTarget' defined in ${
lib.showFiles options.services.cliphist.systemdTarget.files
} has been renamed to `services.cliphist.systemdTargets'."
];
} }

View file

@ -1,4 +1,5 @@
{ {
cliphist-sway-session-target = ./cliphist-sway-session-target.nix; cliphist-sway-session-target = ./cliphist-sway-session-target.nix;
cliphist-extra-options = ./cliphist-extra-options.nix; cliphist-extra-options = ./cliphist-extra-options.nix;
cliphist-multiple-session-targets = ./cliphist-multiple-session-targets.nix;
} }