1{ lib, pkgs, config, ... }:
2with lib;
3let
4 cfg = config.services.pict-rs;
5in
6{
7 meta.maintainers = with maintainers; [ happysalada ];
8 meta.doc = ./pict-rs.md;
9
10 options.services.pict-rs = {
11 enable = mkEnableOption (lib.mdDoc "pict-rs server");
12 dataDir = mkOption {
13 type = types.path;
14 default = "/var/lib/pict-rs";
15 description = lib.mdDoc ''
16 The directory where to store the uploaded images.
17 '';
18 };
19 address = mkOption {
20 type = types.str;
21 default = "127.0.0.1";
22 description = lib.mdDoc ''
23 The IPv4 address to deploy the service to.
24 '';
25 };
26 port = mkOption {
27 type = types.port;
28 default = 8080;
29 description = lib.mdDoc ''
30 The port which to bind the service to.
31 '';
32 };
33 };
34 config = lib.mkIf cfg.enable {
35 systemd.services.pict-rs = {
36 environment = {
37 PICTRS__PATH = cfg.dataDir;
38 PICTRS__ADDR = "${cfg.address}:${toString cfg.port}";
39 };
40 wantedBy = [ "multi-user.target" ];
41 serviceConfig = {
42 DynamicUser = true;
43 StateDirectory = "pict-rs";
44 ExecStart = "${pkgs.pict-rs}/bin/pict-rs";
45 };
46 };
47 };
48}