2024-08-01 18:27:47 +00:00
|
|
|
{ config, lib, ... }:
|
|
|
|
let
|
2024-07-23 20:22:23 +00:00
|
|
|
cfg = config.services.tclip;
|
2024-08-01 18:27:47 +00:00
|
|
|
in
|
|
|
|
{
|
2024-07-23 20:22:23 +00:00
|
|
|
options.services.tclip = {
|
|
|
|
enable = lib.mkEnableOption "tclip service";
|
|
|
|
|
|
|
|
hostname = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
|
|
|
default = "paste";
|
|
|
|
description = "The hostname to use on your tailnet";
|
|
|
|
};
|
|
|
|
|
|
|
|
dataLocation = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
|
|
|
default = "/var/lib/tclip";
|
|
|
|
description = "Where program data is stored";
|
|
|
|
};
|
|
|
|
|
|
|
|
tsnetVerbose = lib.mkOption {
|
|
|
|
type = lib.types.bool;
|
|
|
|
default = false;
|
|
|
|
description = "Log verbosely to stderr";
|
|
|
|
};
|
|
|
|
|
|
|
|
useFunnel = lib.mkOption {
|
|
|
|
type = lib.types.bool;
|
|
|
|
default = false;
|
|
|
|
description = "Expose pastes with tailscale funnel";
|
|
|
|
};
|
|
|
|
|
|
|
|
hideFunnelUsers = lib.mkOption {
|
|
|
|
type = lib.types.bool;
|
|
|
|
default = false;
|
|
|
|
description = "Hide usernamd/image on funnel";
|
|
|
|
};
|
|
|
|
|
|
|
|
httpPort = lib.mkOption {
|
|
|
|
type = lib.types.nullOr lib.types.port;
|
|
|
|
default = null;
|
|
|
|
description = "Expose pastes on an HTTP server at the given port";
|
|
|
|
};
|
|
|
|
|
|
|
|
controlURL = lib.mkOption {
|
|
|
|
type = lib.types.nullOr lib.types.str;
|
|
|
|
default = null;
|
|
|
|
description = "Custom control server (e.g. headscale)";
|
|
|
|
};
|
|
|
|
|
|
|
|
disableHTTPS = lib.mkOption {
|
|
|
|
type = lib.types.bool;
|
|
|
|
default = false;
|
|
|
|
description = "Disable serving on HTTPS";
|
|
|
|
};
|
|
|
|
|
|
|
|
package = lib.mkOption {
|
|
|
|
type = lib.types.package;
|
|
|
|
description = "The tclip package to use";
|
|
|
|
};
|
|
|
|
|
|
|
|
authKey = lib.mkOption {
|
|
|
|
type = lib.types.nullOr lib.types.str;
|
|
|
|
default = null;
|
|
|
|
description = "Tailscale auth key";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
|
|
systemd.services.tclip = {
|
|
|
|
description = "tclip Service";
|
2024-08-01 18:27:47 +00:00
|
|
|
after = [ "network.target" ];
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
2024-07-23 20:22:23 +00:00
|
|
|
|
|
|
|
serviceConfig = {
|
2024-08-01 18:27:47 +00:00
|
|
|
ExecStart =
|
|
|
|
let
|
|
|
|
args =
|
|
|
|
lib.optionals (cfg.httpPort != null) [ "--http-port=${cfg.httpPort}" ]
|
|
|
|
++ lib.optionals (cfg.controlURL != null) [ "--control-url=${cfg.controlURL}" ]
|
|
|
|
++ [
|
|
|
|
(lib.optionalString cfg.disableHTTPS "--disable-https")
|
|
|
|
"--hostname=${cfg.hostname}"
|
|
|
|
"--data-location=${cfg.dataLocation}"
|
|
|
|
(lib.optionalString cfg.tsnetVerbose "--tsnet-verbose")
|
|
|
|
(lib.optionalString cfg.useFunnel "--use-funnel")
|
|
|
|
(lib.optionalString cfg.hideFunnelUsers "--hide-funnel-users")
|
|
|
|
];
|
|
|
|
in
|
|
|
|
"${cfg.package}/bin/tclipd ${lib.concatStringsSep " " args}";
|
2024-07-23 20:22:23 +00:00
|
|
|
Restart = "always";
|
|
|
|
User = "tclip";
|
|
|
|
Group = "tclip";
|
2024-08-01 18:27:47 +00:00
|
|
|
Environment = [ "TS_AUTHKEY=${cfg.authKey}" ];
|
2024-07-23 20:22:23 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
# Create user and group
|
|
|
|
users.users.tclip = {
|
|
|
|
isSystemUser = true;
|
|
|
|
group = "tclip";
|
|
|
|
home = cfg.dataLocation;
|
|
|
|
createHome = true;
|
|
|
|
};
|
|
|
|
|
2024-08-01 18:27:47 +00:00
|
|
|
users.groups.tclip = { };
|
2024-07-23 20:22:23 +00:00
|
|
|
};
|
|
|
|
}
|