blob: 2532cfc3c0b1b604413fe59a62b9a12e35a3c2e6 (
plain)
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
51
52
53
54
|
{ config, pkgs, lib, utils, ... }:
let
cfg = config.services.abs-podcast-autoplaylist;
enabledAttrs = lib.filterAttrs (_name: { enable, ... }: enable) cfg;
in {
options = {
services.abs-podcast-autoplaylist = lib.mkOption {
default = {};
type = lib.types.attrsOf (lib.types.submodule ({ name, ... }: {
options = {
enable = lib.mkEnableOption "this instance of abs-podcast-autoplaylist" // {
default = true;
};
cron = lib.mkOption {
type = lib.types.str;
default = "*-*-* *:00/30:00";
};
configSecret = lib.mkOption {
type = lib.types.str;
default = "abs-podcast-autoplaylist-${name}.toml";
};
};
}));
};
};
config = lib.mkIf (enabledAttrs != {}) {
systemd.services = {
"abs-podcast-autoplaylist@" = {
serviceConfig = {
WorkingDirectory = "%d";
DynamicUser = true;
ProtectHome = true;
PrivateTmp = true;
PrivateDevices = true;
Type = "oneshot";
ExecStart = "${lib.getExe pkgs.abs-podcast-autoplaylist} %I.toml";
};
};
} // lib.mapAttrs' (name: { configSecret, ... }: lib.nameValuePair "abs-podcast-autoplaylist@${utils.escapeSystemdPath name}" {
overrideStrategy = "asDropin";
serviceConfig = {
LoadCredential = "${name}.toml:${config.sops.secrets.${configSecret}.path}";
};
}) enabledAttrs;
systemd.timers = lib.mapAttrs' (name: { cron, ... }: lib.nameValuePair "abs-podcast-autoplaylist@${utils.escapeSystemdPath name}" {
wantedBy = [ "timers.target" ];
timerConfig.OnCalendar = cron;
}) enabledAttrs;
};
}
|