52 lines
1.3 KiB
Nix
Raw Normal View History

2023-03-23 01:58:10 +03:00
{ config, lib, pkgs, ... }:
let
backend = config.virtualisation.oci-containers.backend;
pod-name = "media-stack";
open-ports = [
# caddy
"127.0.0.1:8180:8180"
];
2023-12-30 04:43:48 +03:00
pod-dns = "192.168.0.1";
2023-03-23 01:58:10 +03:00
in {
2022-04-04 14:53:16 +03:00
imports = [
./caddy.nix
2023-03-23 01:58:10 +03:00
./jackett.nix
2022-05-19 21:46:31 +03:00
./jellyfin.nix
./kavita.nix
./lidarr.nix
2023-03-23 01:58:10 +03:00
./medusa.nix
2022-04-04 14:53:16 +03:00
./qbittorrent.nix
./radarr.nix
2023-03-23 01:58:10 +03:00
./recyclarr.nix
2022-04-04 14:53:16 +03:00
./sonarr.nix
];
2023-03-23 01:58:10 +03:00
systemd.services."podman-create-${pod-name}" = let
portsMapping = lib.concatMapStrings (port: " -p " + port) open-ports;
2023-11-22 06:16:07 +03:00
start = pkgs.writeShellScript "create-pod-${pod-name}" ''
podman pod exists ${pod-name} || podman pod create -n ${pod-name} ${portsMapping} --dns ${pod-dns}
2023-03-23 01:58:10 +03:00
'';
2023-11-22 06:16:07 +03:00
stop = "podman pod rm -i -f ${pod-name}";
in rec {
2023-03-23 01:58:10 +03:00
path = [ pkgs.coreutils config.virtualisation.podman.package ];
before = [
"${backend}-media-caddy.service"
"${backend}-jackett.service"
2022-04-04 14:53:16 +03:00
"${backend}-jellyfin.service"
2022-05-19 21:46:31 +03:00
"${backend}-kavita.service"
"${backend}-lidarr.service"
2023-03-23 01:58:10 +03:00
"${backend}-medusa.service"
2022-05-19 21:46:31 +03:00
"${backend}-qbittorrent.service"
"${backend}-radarr.service"
2023-03-23 01:58:10 +03:00
"${backend}-recyclarr.service"
"${backend}-sonarr.service"
2022-04-04 14:53:16 +03:00
];
2023-11-22 06:16:07 +03:00
requiredBy = before;
2023-03-23 01:58:10 +03:00
serviceConfig = {
Type = "oneshot";
RemainAfterExit = "yes";
ExecStart = start;
2023-11-22 06:16:07 +03:00
ExecStop = stop;
2023-03-23 01:58:10 +03:00
};
2022-04-04 14:53:16 +03:00
};
2023-03-23 01:58:10 +03:00
}