NixOS/system/podman/servarr/sonarr.nix

81 lines
2 KiB
Nix
Raw Permalink Normal View History

2024-06-25 22:45:00 +07:00
{ config, lib, ... }:
let
podman = config.profile.podman;
sonarr = podman.servarr.sonarr;
name = "sonarr";
2024-06-26 13:26:32 +07:00
name-anime = "${name}-anime";
2024-06-25 22:45:00 +07:00
ip = "10.88.2.3";
2024-06-26 13:26:32 +07:00
ip-anime = "10.88.2.33";
2024-06-25 22:45:00 +07:00
image = "lscr.io/linuxserver/sonarr:latest";
root = "/nas/mediaserver/servarr";
2024-06-26 13:26:32 +07:00
configVolume = "${root}/${name}";
configVolumeAnime = "${root}/${name-anime}";
2024-06-25 22:45:00 +07:00
mediaVolume = "${root}/data";
domain = "${name}.tigor.web.id";
2024-06-26 13:26:32 +07:00
domain-anime = "${name-anime}.tigor.web.id";
2024-06-25 22:45:00 +07:00
user = config.profile.user;
uid = toString user.uid;
gid = toString user.gid;
inherit (lib) mkIf;
in
{
config = mkIf (podman.enable && sonarr.enable) {
services.caddy.virtualHosts.${domain}.extraConfig = ''
reverse_proxy ${ip}:8989
'';
2024-06-26 13:26:32 +07:00
services.caddy.virtualHosts.${domain-anime}.extraConfig = ''
reverse_proxy ${ip-anime}:8989
'';
2024-06-25 22:45:00 +07:00
system.activationScripts."podman-${name}" = ''
2024-06-26 13:26:32 +07:00
mkdir -p ${configVolume} ${mediaVolume} ${configVolumeAnime}
chown ${uid}:${gid} ${mediaVolume} ${configVolume} ${configVolumeAnime}
2024-06-25 22:45:00 +07:00
'';
virtualisation.oci-containers.containers.${name} = {
inherit image;
hostname = name;
autoStart = true;
environment = {
PUID = uid;
PGID = gid;
TZ = "Asia/Jakarta";
};
volumes = [
"${configVolume}:/config"
"${mediaVolume}:/data"
];
extraOptions = [
"--ip=${ip}"
"--network=podman"
];
labels = {
"io.containers.autoupdate" = "registry";
};
};
2024-06-26 13:26:32 +07:00
virtualisation.oci-containers.containers.${name-anime} = {
inherit image;
hostname = name-anime;
autoStart = true;
environment = {
PUID = uid;
PGID = gid;
TZ = "Asia/Jakarta";
};
volumes = [
"${configVolumeAnime}:/config"
"${mediaVolume}:/data"
];
extraOptions = [
"--ip=${ip-anime}"
"--network=podman"
];
labels = {
"io.containers.autoupdate" = "registry";
};
};
2024-06-25 22:45:00 +07:00
};
}