2021-09-30 12:15:08 +00:00
|
|
|
{ lib, pkgs, config, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
cfg = config.services.pict-rs;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
meta.maintainers = with maintainers; [ happysalada ];
|
2023-01-24 23:33:40 +00:00
|
|
|
meta.doc = ./pict-rs.md;
|
2021-09-30 12:15:08 +00:00
|
|
|
|
|
|
|
options.services.pict-rs = {
|
2022-08-28 19:18:44 +00:00
|
|
|
enable = mkEnableOption (lib.mdDoc "pict-rs server");
|
2021-09-30 12:15:08 +00:00
|
|
|
dataDir = mkOption {
|
|
|
|
type = types.path;
|
|
|
|
default = "/var/lib/pict-rs";
|
2022-07-28 21:19:15 +00:00
|
|
|
description = lib.mdDoc ''
|
2021-09-30 12:15:08 +00:00
|
|
|
The directory where to store the uploaded images.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
address = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "127.0.0.1";
|
2022-07-28 21:19:15 +00:00
|
|
|
description = lib.mdDoc ''
|
2021-09-30 12:15:08 +00:00
|
|
|
The IPv4 address to deploy the service to.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
port = mkOption {
|
|
|
|
type = types.port;
|
|
|
|
default = 8080;
|
2022-07-28 21:19:15 +00:00
|
|
|
description = lib.mdDoc ''
|
2021-09-30 12:15:08 +00:00
|
|
|
The port which to bind the service to.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
|
|
systemd.services.pict-rs = {
|
|
|
|
environment = {
|
|
|
|
PICTRS_PATH = cfg.dataDir;
|
|
|
|
PICTRS_ADDR = "${cfg.address}:${toString cfg.port}";
|
|
|
|
};
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
serviceConfig = {
|
|
|
|
DynamicUser = true;
|
|
|
|
StateDirectory = "pict-rs";
|
|
|
|
ExecStart = "${pkgs.pict-rs}/bin/pict-rs";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|