at 23.11-pre 1.4 kB view raw
1{ config, lib, pkgs, ... }: 2let 3 cfg = config.services.podgrab; 4in 5{ 6 options.services.podgrab = with lib; { 7 enable = mkEnableOption (lib.mdDoc "Podgrab, a self-hosted podcast manager"); 8 9 passwordFile = mkOption { 10 type = with types; nullOr str; 11 default = null; 12 example = "/run/secrets/password.env"; 13 description = lib.mdDoc '' 14 The path to a file containing the PASSWORD environment variable 15 definition for Podgrab's authentication. 16 ''; 17 }; 18 19 port = mkOption { 20 type = types.port; 21 default = 8080; 22 example = 4242; 23 description = lib.mdDoc "The port on which Podgrab will listen for incoming HTTP traffic."; 24 }; 25 }; 26 27 config = lib.mkIf cfg.enable { 28 systemd.services.podgrab = { 29 description = "Podgrab podcast manager"; 30 wantedBy = [ "multi-user.target" ]; 31 environment = { 32 CONFIG = "/var/lib/podgrab/config"; 33 DATA = "/var/lib/podgrab/data"; 34 GIN_MODE = "release"; 35 PORT = toString cfg.port; 36 }; 37 serviceConfig = { 38 DynamicUser = true; 39 EnvironmentFile = lib.optionals (cfg.passwordFile != null) [ 40 cfg.passwordFile 41 ]; 42 ExecStart = "${pkgs.podgrab}/bin/podgrab"; 43 WorkingDirectory = "${pkgs.podgrab}/share"; 44 StateDirectory = [ "podgrab/config" "podgrab/data" ]; 45 }; 46 }; 47 }; 48 49 meta.maintainers = with lib.maintainers; [ ambroisie ]; 50}