about summary refs log tree commit diff
path: root/nixos/modules/services/misc/podgrab.nix
blob: c596122fd31c45bbe8907b5184ccac77407c449e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
{ config, lib, pkgs, ... }:
let
  cfg = config.services.podgrab;
in
{
  options.services.podgrab = with lib; {
    enable = mkEnableOption (lib.mdDoc "Podgrab, a self-hosted podcast manager");

    passwordFile = mkOption {
      type = with types; nullOr str;
      default = null;
      example = "/run/secrets/password.env";
      description = lib.mdDoc ''
        The path to a file containing the PASSWORD environment variable
        definition for Podgrab's authentication.
      '';
    };

    port = mkOption {
      type = types.port;
      default = 8080;
      example = 4242;
      description = lib.mdDoc "The port on which Podgrab will listen for incoming HTTP traffic.";
    };
  };

  config = lib.mkIf cfg.enable {
    systemd.services.podgrab = {
      description = "Podgrab podcast manager";
      wantedBy = [ "multi-user.target" ];
      environment = {
        CONFIG = "/var/lib/podgrab/config";
        DATA = "/var/lib/podgrab/data";
        GIN_MODE = "release";
        PORT = toString cfg.port;
      };
      serviceConfig = {
        DynamicUser = true;
        EnvironmentFile = lib.optionals (cfg.passwordFile != null) [
          cfg.passwordFile
        ];
        ExecStart = "${pkgs.podgrab}/bin/podgrab";
        WorkingDirectory = "${pkgs.podgrab}/share";
        StateDirectory = [ "podgrab/config" "podgrab/data" ];
      };
    };
  };

  meta.maintainers = with lib.maintainers; [ ambroisie ];
}