at 22.05-pre 1.3 kB view raw
1{ lib, pkgs, config, ... }: 2with lib; 3let 4 cfg = config.services.pict-rs; 5in 6{ 7 meta.maintainers = with maintainers; [ happysalada ]; 8 # Don't edit the docbook xml directly, edit the md and generate it: 9 # `pandoc pict-rs.md -t docbook --top-level-division=chapter --extract-media=media -f markdown+smart > pict-rs.xml` 10 meta.doc = ./pict-rs.xml; 11 12 options.services.pict-rs = { 13 enable = mkEnableOption "pict-rs server"; 14 dataDir = mkOption { 15 type = types.path; 16 default = "/var/lib/pict-rs"; 17 description = '' 18 The directory where to store the uploaded images. 19 ''; 20 }; 21 address = mkOption { 22 type = types.str; 23 default = "127.0.0.1"; 24 description = '' 25 The IPv4 address to deploy the service to. 26 ''; 27 }; 28 port = mkOption { 29 type = types.port; 30 default = 8080; 31 description = '' 32 The port which to bind the service to. 33 ''; 34 }; 35 }; 36 config = lib.mkIf cfg.enable { 37 systemd.services.pict-rs = { 38 environment = { 39 PICTRS_PATH = cfg.dataDir; 40 PICTRS_ADDR = "${cfg.address}:${toString cfg.port}"; 41 }; 42 wantedBy = [ "multi-user.target" ]; 43 serviceConfig = { 44 DynamicUser = true; 45 StateDirectory = "pict-rs"; 46 ExecStart = "${pkgs.pict-rs}/bin/pict-rs"; 47 }; 48 }; 49 }; 50}