summaryrefslogtreecommitdiff
path: root/modules/abs-podcast-autoplaylist.nix
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2025-05-10 12:53:58 +0200
committerGregor Kleen <gkleen@yggdrasil.li>2025-05-10 12:53:58 +0200
commit81cc664d4250189c9026edfb042e24c6806448ee (patch)
tree710579dbd9633a33179a8f373ad6fa1b7808c600 /modules/abs-podcast-autoplaylist.nix
parent83e0c7df55234bc5e7c2c918ceb587786af6d155 (diff)
downloadnixos-81cc664d4250189c9026edfb042e24c6806448ee.tar
nixos-81cc664d4250189c9026edfb042e24c6806448ee.tar.gz
nixos-81cc664d4250189c9026edfb042e24c6806448ee.tar.bz2
nixos-81cc664d4250189c9026edfb042e24c6806448ee.tar.xz
nixos-81cc664d4250189c9026edfb042e24c6806448ee.zip
abs-podcast-autoplaylist
Diffstat (limited to 'modules/abs-podcast-autoplaylist.nix')
-rw-r--r--modules/abs-podcast-autoplaylist.nix54
1 files changed, 54 insertions, 0 deletions
diff --git a/modules/abs-podcast-autoplaylist.nix b/modules/abs-podcast-autoplaylist.nix
new file mode 100644
index 00000000..2532cfc3
--- /dev/null
+++ b/modules/abs-podcast-autoplaylist.nix
@@ -0,0 +1,54 @@
1{ config, pkgs, lib, utils, ... }:
2
3let
4 cfg = config.services.abs-podcast-autoplaylist;
5
6 enabledAttrs = lib.filterAttrs (_name: { enable, ... }: enable) cfg;
7in {
8 options = {
9 services.abs-podcast-autoplaylist = lib.mkOption {
10 default = {};
11 type = lib.types.attrsOf (lib.types.submodule ({ name, ... }: {
12 options = {
13 enable = lib.mkEnableOption "this instance of abs-podcast-autoplaylist" // {
14 default = true;
15 };
16 cron = lib.mkOption {
17 type = lib.types.str;
18 default = "*-*-* *:00/30:00";
19 };
20 configSecret = lib.mkOption {
21 type = lib.types.str;
22 default = "abs-podcast-autoplaylist-${name}.toml";
23 };
24 };
25 }));
26 };
27 };
28
29 config = lib.mkIf (enabledAttrs != {}) {
30 systemd.services = {
31 "abs-podcast-autoplaylist@" = {
32 serviceConfig = {
33 WorkingDirectory = "%d";
34 DynamicUser = true;
35 ProtectHome = true;
36 PrivateTmp = true;
37 PrivateDevices = true;
38 Type = "oneshot";
39 ExecStart = "${lib.getExe pkgs.abs-podcast-autoplaylist} %I.toml";
40 };
41 };
42 } // lib.mapAttrs' (name: { configSecret, ... }: lib.nameValuePair "abs-podcast-autoplaylist@${utils.escapeSystemdPath name}" {
43 overrideStrategy = "asDropin";
44 serviceConfig = {
45 LoadCredential = "${name}.toml:${config.sops.secrets.${configSecret}.path}";
46 };
47 }) enabledAttrs;
48
49 systemd.timers = lib.mapAttrs' (name: { cron, ... }: lib.nameValuePair "abs-podcast-autoplaylist@${utils.escapeSystemdPath name}" {
50 wantedBy = [ "timers.target" ];
51 timerConfig.OnCalendar = cron;
52 }) enabledAttrs;
53 };
54}