aboutsummaryrefslogtreecommitdiff
path: root/infra/libkookie/home-manager/modules/services/pbgopy.nix
blob: a95ad959f008ef87ecf427546009c2ef49c0b974 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
{ config, lib, pkgs, ... }:

with lib;

let
  cfg = config.services.pbgopy;
  package = pkgs.pbgopy;
in {
  meta.maintainers = [ maintainers.ivar ];

  options.services.pbgopy = {
    enable = mkEnableOption "pbgopy";

    cache.ttl = mkOption {
      type = types.str;
      default = "24h";
      example = "10m";
      description = ''
        The TTL for the cache. Use <literal>"0s"</literal> to disable it.
      '';
    };
  };

  config = mkIf cfg.enable {
    home.packages = [ package ];

    systemd.user.services.pbgopy = {
      Unit = {
        Description = "pbgopy server for sharing the clipboard between devices";
        After = [ "graphical-session-pre.target" ];
        PartOf = [ "graphical-session.target" ];
      };
      Service = {
        ExecStart = "${package}/bin/pbgopy serve --ttl ${cfg.cache.ttl}";
        Restart = "on-abort";
      };
      Install = { WantedBy = [ "graphical-session.target" ]; };
    };
  };
}