fork/home-manager

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

Janikservices.cliphist: add module (#4445)3b67ae3f

master
1.4 KiB50 linesraw
1{ config, lib, pkgs, ... }:
2let cfg = config.services.cliphist;
3in {
4  meta.maintainers = [ lib.maintainers.janik ];
5
6  options.services.cliphist = {
7    enable =
8      lib.mkEnableOption "cliphist, a clipboard history “manager” for wayland";
9
10    package = lib.mkPackageOption pkgs "cliphist" { };
11
12    systemdTarget = lib.mkOption {
13      type = lib.types.str;
14      default = "graphical-session.target";
15      example = "sway-session.target";
16      description = ''
17        The systemd target that will automatically start the cliphist 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 = lib.mkIf cfg.enable {
27    assertions = [
28      (lib.hm.assertions.assertPlatform "services.cliphist" pkgs
29        lib.platforms.linux)
30    ];
31
32    home.packages = [ cfg.package ];
33
34    systemd.user.services.cliphist = {
35      Unit = {
36        Description = "Clipboard management daemon";
37        PartOf = [ "graphical-session.target" ];
38      };
39
40      Service = {
41        Type = "simple";
42        ExecStart =
43          "${pkgs.wl-clipboard}/bin/wl-paste --watch ${cfg.package}/bin/cliphist store";
44        Restart = "on-failure";
45      };
46
47      Install = { WantedBy = [ cfg.systemdTarget ]; };
48    };
49  };
50}