1
0
Fork 0
selfhostblocks/test/modules/arr.nix

211 lines
5.2 KiB
Nix
Raw Normal View History

{ pkgs, lib, ... }:
let
anyOpt = default: lib.mkOption {
type = lib.types.anything;
inherit default;
};
testConfig = m:
let
cfg = (lib.evalModules {
specialArgs = { inherit pkgs; };
modules = [
{
options = {
systemd = anyOpt {};
shb.backup = anyOpt {};
shb.nginx = anyOpt {};
users = anyOpt {};
services.nginx = anyOpt {};
services.bazarr = anyOpt {};
services.jackett = anyOpt {};
services.lidarr = anyOpt {};
services.radarr = anyOpt {};
services.readarr = anyOpt {};
services.sonarr = anyOpt {};
};
}
../../modules/services/arr.nix
m
];
}).config;
systemdRedacted = lib.filterAttrsRecursive (n: v: n != "preStart") cfg.systemd;
in {
inherit (cfg) services users;
systemd = systemdRedacted;
shb = { inherit (cfg.shb) backup nginx; };
};
in
{
testArrNoOptions = {
expected = {
systemd = {};
shb.backup = {};
shb.nginx = {};
users = {};
services.nginx = {};
services.bazarr = {};
services.jackett = {};
services.lidarr = {};
services.radarr = {};
services.readarr = {};
services.sonarr = {};
};
expr = testConfig {};
};
2023-11-17 08:48:19 +01:00
testRadarr = {
expected = {
systemd.services.radarr = {
serviceConfig = {
StateDirectoryMode = "0750";
UMask = "0027";
};
};
systemd.tmpfiles.rules = [
"d '/var/lib/radarr' 0750 radarr radarr - -"
];
shb.backup.instances.radarr = {
excludePatterns = [
".db-shm"
".db-wal"
".mono"
];
sourceDirectories = [
"/var/lib/radarr"
];
};
2024-05-27 08:10:10 +02:00
shb.nginx.vhosts = [
2023-11-17 08:48:19 +01:00
{
autheliaRules = [
{
domain = "radarr.example.com";
policy = "bypass";
resources = [
"^/api.*"
];
}
{
domain = "radarr.example.com";
policy = "two_factor";
subject = [
"group:arr_user"
];
}
];
domain = "example.com";
authEndpoint = "https://oidc.example.com";
2023-11-17 08:48:19 +01:00
subdomain = "radarr";
upstream = "http://127.0.0.1:7878";
2024-01-12 08:22:46 +01:00
ssl = null;
2023-11-17 08:48:19 +01:00
}
];
users.groups.radarr.members = [ "backup" ];
services.nginx.enable = true;
2023-11-17 08:48:19 +01:00
services.bazarr = {};
services.jackett = {};
services.lidarr = {};
services.radarr = {
enable = true;
dataDir = "/var/lib/radarr";
user = "radarr";
group = "radarr";
};
services.readarr = {};
services.sonarr = {};
};
expr = testConfig {
services.radarr.user = "radarr";
services.radarr.group = "radarr";
shb.arr.radarr = {
subdomain = "radarr";
domain = "example.com";
enable = true;
authEndpoint = "https://oidc.example.com";
2023-11-17 08:48:19 +01:00
settings = {
ApiKey.source = pkgs.writeText "key" "/run/radarr/apikey";
2023-11-17 08:48:19 +01:00
};
};
};
};
testRadarrWithBackup = {
expected = {
systemd.services.radarr = {
serviceConfig = {
StateDirectoryMode = "0750";
UMask = "0027";
};
};
systemd.tmpfiles.rules = [
"d '/var/lib/radarr' 0750 radarr radarr - -"
];
shb.backup.instances = {
radarr = {
enable = true;
sourceDirectories = [ "/var/lib/radarr" ];
excludePatterns = [ ".db-shm" ".db-wal" ".mono" ];
};
};
2024-05-25 00:01:45 +02:00
shb.nginx.vhosts = [
2023-11-17 08:48:19 +01:00
{
autheliaRules = [
{
domain = "radarr.example.com";
policy = "bypass";
resources = [
"^/api.*"
];
}
{
domain = "radarr.example.com";
policy = "two_factor";
subject = [
"group:arr_user"
];
}
];
domain = "example.com";
authEndpoint = "https://oidc.example.com";
2023-11-17 08:48:19 +01:00
subdomain = "radarr";
upstream = "http://127.0.0.1:7878";
2024-01-12 08:22:46 +01:00
ssl = null;
2023-11-17 08:48:19 +01:00
}
];
users.groups.radarr.members = [ "backup" ];
services.nginx.enable = true;
2023-11-17 08:48:19 +01:00
services.bazarr = {};
services.jackett = {};
services.lidarr = {};
services.radarr = {
enable = true;
dataDir = "/var/lib/radarr";
user = "radarr";
group = "radarr";
};
services.readarr = {};
services.sonarr = {};
};
expr = testConfig {
services.radarr.user = "radarr";
services.radarr.group = "radarr";
shb.arr.radarr = {
subdomain = "radarr";
domain = "example.com";
enable = true;
authEndpoint = "https://oidc.example.com";
2023-11-17 08:48:19 +01:00
settings = {
ApiKey.source = pkgs.writeText "key" "/run/radarr/apikey";
2023-11-17 08:48:19 +01:00
};
backupCfg = {
enable = true;
};
};
};
};
}