fork/home-manager

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

Robert HelgessonMerge PR #421575790441

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