2023-10-15 14:03:18 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
let cfg = config.services.cliphist;
|
|
|
|
in {
|
2024-07-05 01:18:45 +02:00
|
|
|
meta.maintainers = [ lib.hm.maintainers.janik ];
|
2023-10-15 14:03:18 +02:00
|
|
|
|
|
|
|
options.services.cliphist = {
|
|
|
|
enable =
|
|
|
|
lib.mkEnableOption "cliphist, a clipboard history “manager” for wayland";
|
|
|
|
|
|
|
|
package = lib.mkPackageOption pkgs "cliphist" { };
|
|
|
|
|
2024-04-28 23:51:59 +02:00
|
|
|
allowImages = lib.mkOption {
|
|
|
|
type = lib.types.bool;
|
|
|
|
default = true;
|
|
|
|
description = ''
|
|
|
|
Store images in clipboard history.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2024-05-05 09:37:54 +02:00
|
|
|
extraOptions = lib.mkOption {
|
|
|
|
type = with lib.types; listOf str;
|
|
|
|
default = [ "-max-dedupe-search" "10" "-max-items" "500" ];
|
|
|
|
description = ''
|
|
|
|
Flags to append to the cliphist command.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2023-10-15 14:03:18 +02:00
|
|
|
systemdTarget = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
|
|
|
default = "graphical-session.target";
|
|
|
|
example = "sway-session.target";
|
|
|
|
description = ''
|
|
|
|
The systemd target that will automatically start the cliphist service.
|
|
|
|
|
|
|
|
When setting this value to `"sway-session.target"`,
|
|
|
|
make sure to also enable {option}`wayland.windowManager.sway.systemd.enable`,
|
|
|
|
otherwise the service may never be started.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-05-05 09:37:54 +02:00
|
|
|
config = let extraOptionsStr = lib.escapeShellArgs cfg.extraOptions;
|
|
|
|
in lib.mkIf cfg.enable {
|
2023-10-15 14:03:18 +02:00
|
|
|
assertions = [
|
|
|
|
(lib.hm.assertions.assertPlatform "services.cliphist" pkgs
|
|
|
|
lib.platforms.linux)
|
|
|
|
];
|
|
|
|
|
|
|
|
home.packages = [ cfg.package ];
|
|
|
|
|
|
|
|
systemd.user.services.cliphist = {
|
|
|
|
Unit = {
|
|
|
|
Description = "Clipboard management daemon";
|
|
|
|
PartOf = [ "graphical-session.target" ];
|
|
|
|
};
|
|
|
|
|
|
|
|
Service = {
|
|
|
|
Type = "simple";
|
|
|
|
ExecStart =
|
2024-05-05 09:37:54 +02:00
|
|
|
"${pkgs.wl-clipboard}/bin/wl-paste --watch ${cfg.package}/bin/cliphist ${extraOptionsStr} store";
|
2023-10-15 14:03:18 +02:00
|
|
|
Restart = "on-failure";
|
|
|
|
};
|
|
|
|
|
|
|
|
Install = { WantedBy = [ cfg.systemdTarget ]; };
|
|
|
|
};
|
2024-04-28 23:51:59 +02:00
|
|
|
|
|
|
|
systemd.user.services.cliphist-images = lib.mkIf cfg.allowImages {
|
|
|
|
Unit = {
|
|
|
|
Description = "Clipboard management daemon - images";
|
|
|
|
PartOf = [ "graphical-session.target" ];
|
|
|
|
};
|
|
|
|
|
|
|
|
Service = {
|
|
|
|
Type = "simple";
|
|
|
|
ExecStart =
|
2024-05-05 09:37:54 +02:00
|
|
|
"${pkgs.wl-clipboard}/bin/wl-paste --type image --watch ${cfg.package}/bin/cliphist ${extraOptionsStr} store";
|
2024-04-28 23:51:59 +02:00
|
|
|
Restart = "on-failure";
|
|
|
|
};
|
|
|
|
|
|
|
|
Install = { WantedBy = [ cfg.systemdTarget ]; };
|
|
|
|
};
|
2023-10-15 14:03:18 +02:00
|
|
|
};
|
|
|
|
}
|