1 { config, lib, pkgs, ... }:
3 cfg = config.services.podgrab;
5 stateDir = "/var/lib/podgrab";
8 options.services.podgrab = with lib; {
9 enable = mkEnableOption "Podgrab, a self-hosted podcast manager";
11 passwordFile = mkOption {
12 type = with types; nullOr str;
14 example = "/run/secrets/password.env";
16 The path to a file containing the PASSWORD environment variable
17 definition for Podgrab's authentication.
25 description = "The port on which Podgrab will listen for incoming HTTP traffic.";
28 dataDirectory = mkOption {
30 default = "${stateDir}/data";
31 example = "/mnt/podcasts";
32 description = "Directory to store downloads.";
38 description = "User under which Podgrab runs, and which owns the download directory.";
44 description = "Group under which Podgrab runs, and which owns the download directory.";
48 config = lib.mkIf cfg.enable {
49 systemd.tmpfiles.settings."10-pyload" = {
50 ${cfg.dataDirectory}.d = { inherit (cfg) user group; };
53 systemd.services.podgrab = {
54 description = "Podgrab podcast manager";
55 wantedBy = [ "multi-user.target" ];
57 CONFIG = "${stateDir}/config";
58 DATA = cfg.dataDirectory;
60 PORT = toString cfg.port;
65 EnvironmentFile = lib.optionals (cfg.passwordFile != null) [
68 ExecStart = "${pkgs.podgrab}/bin/podgrab";
69 WorkingDirectory = "${pkgs.podgrab}/share";
70 StateDirectory = [ "podgrab/config" ];
74 users.users.podgrab = lib.mkIf (cfg.user == "podgrab") {
79 users.groups.podgrab = lib.mkIf (cfg.group == "podgrab") { };
82 meta.maintainers = with lib.maintainers; [ ambroisie ];