yep, more dotfiles
1{ config 2, lib 3, pkgs 4, ... 5}: 6 7let 8 cfg = config.services.wl-clip-persist; 9in 10{ 11 options.services.wl-clip-persist = with lib; { 12 enable = mkEnableOption ""; 13 14 package = mkPackageOption pkgs "wl-clip-persist" { }; 15 16 clipboard = mkOption { 17 description = "The clipboard type to operate on"; 18 default = "regular"; 19 type = types.enum [ "regular" "primary" "both" ]; 20 }; 21 22 display = mkOption { 23 description = "The wayland display to operate on"; 24 default = null; 25 type = types.nullOr types.str; 26 }; 27 28 ignoreEventOnError = mkOption { 29 description = "Only handle selection events where no error occurred"; 30 default = null; 31 type = types.nullOr types.bool; 32 }; 33 34 allMimeTypeRegex = mkOption { 35 description = "Only handle selection events where all offered MIME types have a match for the regex"; 36 default = null; 37 type = types.nullOr types.str; 38 }; 39 40 interruptOldClipboardRequests = mkOption { 41 description = "Interrupt trying to send the old clipboard to other programs when the clipboard has been updated"; 42 default = null; 43 type = types.nullOr types.bool; 44 }; 45 46 selectionSizeLimit = mkOption { 47 description = "Only handle selection events whose total data size does not exceed the size limit"; 48 default = null; 49 type = types.nullOr types.int; 50 }; 51 52 readTimeout = mkOption { 53 description = "Timeout for trying to get the current clipboard"; 54 default = 500; 55 type = types.int; 56 }; 57 58 ignoreEventOnTimeout = mkOption { 59 description = "Only handle selection events where no timeout occurred"; 60 default = null; 61 type = types.nullOr types.bool; 62 }; 63 64 writeTimeout = mkOption { 65 description = "Timeout for trying to send the current clipboard to other programs"; 66 default = 3000; 67 type = types.int; 68 }; 69 }; 70 71 config = lib.mkIf cfg.enable { 72 systemd.user.services.wl-clip-persist = { 73 Unit = { 74 Description = "wl-clip-persist system service"; 75 PartOf = [ "graphical-session.target" ]; 76 BindsTo = [ "graphical-session.target" ]; 77 }; 78 79 Service = { 80 Type = "simple"; 81 ExecStart = "${lib.getExe cfg.package} ${lib.cli.toGNUCommandLineShell {} { 82 clipboard = cfg.clipboard; 83 display = cfg.display; 84 ignore-event-on-error = cfg.ignoreEventOnError; 85 all-mime-type-regex = cfg.allMimeTypeRegex; 86 interrupt-old-clipboard-requests = cfg.interruptOldClipboardRequests; 87 selection-size-limit = cfg.selectionSizeLimit; 88 read-timeout = cfg.readTimeout; 89 ignore-event-on-timeout = cfg.ignoreEventOnTimeout; 90 write-timeout = cfg.writeTimeout; 91 }}"; 92 Restart = "on-failure"; 93 TimeoutStopSec = 15; 94 }; 95 96 Install.WantedBy = lib.mkDefault [ "graphical-session.target" ]; 97 }; 98 }; 99}