2020-12-03 03:55:37 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
2021-04-22 23:46:05 +02:00
|
|
|
|
2020-12-03 03:55:37 +01:00
|
|
|
cfg = config.services.pbgopy;
|
|
|
|
package = pkgs.pbgopy;
|
2021-04-22 23:46:05 +02:00
|
|
|
|
|
|
|
commandLine = concatStringsSep " " ([
|
|
|
|
"${package}/bin/pbgopy serve"
|
|
|
|
"--port ${toString cfg.port}"
|
|
|
|
"--ttl ${cfg.cache.ttl}"
|
|
|
|
] ++ optional (cfg.httpAuth != null)
|
|
|
|
"--basic-auth ${escapeShellArg cfg.httpAuth}");
|
|
|
|
|
2020-12-03 03:55:37 +01:00
|
|
|
in {
|
2024-07-03 09:39:20 +02:00
|
|
|
meta.maintainers = [ ];
|
2020-12-03 03:55:37 +01:00
|
|
|
|
|
|
|
options.services.pbgopy = {
|
2023-07-02 01:45:18 +02:00
|
|
|
enable = mkEnableOption "pbgopy";
|
2020-12-03 03:55:37 +01:00
|
|
|
|
2021-04-22 23:46:05 +02:00
|
|
|
port = mkOption {
|
|
|
|
type = types.port;
|
|
|
|
default = 9090;
|
|
|
|
example = 8080;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2021-04-22 23:46:05 +02:00
|
|
|
The port to host the pbgopy server on.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2020-12-03 03:55:37 +01:00
|
|
|
cache.ttl = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "24h";
|
|
|
|
example = "10m";
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2023-07-01 01:30:13 +02:00
|
|
|
The TTL for the cache. Use `"0s"` to disable it.
|
2020-12-03 03:55:37 +01:00
|
|
|
'';
|
|
|
|
};
|
2021-04-22 23:46:05 +02:00
|
|
|
|
|
|
|
httpAuth = mkOption {
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = null;
|
|
|
|
example = "user:pass";
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2021-04-22 23:46:05 +02:00
|
|
|
Basic HTTP authentication's username and password. Both the username and
|
|
|
|
password are escaped.
|
|
|
|
'';
|
|
|
|
};
|
2020-12-03 03:55:37 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2021-07-07 23:24:27 +02:00
|
|
|
assertions = [
|
|
|
|
(lib.hm.assertions.assertPlatform "services.pbgopy" pkgs
|
|
|
|
lib.platforms.linux)
|
|
|
|
];
|
|
|
|
|
2020-12-03 03:55:37 +01:00
|
|
|
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 = {
|
2021-04-22 23:46:05 +02:00
|
|
|
ExecStart = commandLine;
|
2020-12-03 03:55:37 +01:00
|
|
|
Restart = "on-abort";
|
|
|
|
};
|
|
|
|
Install = { WantedBy = [ "graphical-session.target" ]; };
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|