fork/home-manager

git clone https://git.julia.blue/fork/home-manager

Robert HelgessonMerge PR #421575790441

master
1.4 KiB54 linesraw
1{ config, lib, pkgs, ... }:
2
3let
4
5  cfg = config.services.copyq;
6
7in {
8  meta.maintainers = [ lib.maintainers.DamienCassou ];
9
10  options.services.copyq = {
11    enable =
12      lib.mkEnableOption "CopyQ, a clipboard manager with advanced features";
13
14    package = lib.mkPackageOption pkgs "copyq" { };
15
16    systemdTarget = lib.mkOption {
17      type = lib.types.str;
18      default = "graphical-session.target";
19      example = "sway-session.target";
20      description = ''
21        The systemd target that will automatically start the CopyQ service.
22
23        When setting this value to `"sway-session.target"`,
24        make sure to also enable {option}`wayland.windowManager.sway.systemd.enable`,
25        otherwise the service may never be started.
26      '';
27    };
28  };
29
30  config = lib.mkIf cfg.enable {
31    assertions = [
32      (lib.hm.assertions.assertPlatform "services.copyq" pkgs
33        lib.platforms.linux)
34    ];
35
36    home.packages = [ cfg.package ];
37
38    systemd.user.services.copyq = {
39      Unit = {
40        Description = "CopyQ clipboard management daemon";
41        PartOf = [ "graphical-session.target" ];
42        After = [ "graphical-session.target" ];
43      };
44
45      Service = {
46        ExecStart = "${cfg.package}/bin/copyq";
47        Restart = "on-failure";
48        Environment = [ "QT_QPA_PLATFORM=xcb" ];
49      };
50
51      Install = { WantedBy = [ cfg.systemdTarget ]; };
52    };
53  };
54}