Changed option namespace for better compatibility

This commit is contained in:
pazpi 2024-08-27 17:49:31 +02:00
parent fe8045ee55
commit 8b25f46384
26 changed files with 407 additions and 232 deletions

View file

@ -0,0 +1,149 @@
{
config,
pkgs,
lib,
...
}:
let
cfg = config.my.services.download-pod;
in
{
options.my.services.download-pod = {
enable = lib.mkEnableOption "Enable the download searcher stack";
proxy = {
enable = lib.mkEnableOption "Enable proxy for the services";
hostName = lib.mkOption {
default = "example.com";
type = lib.types.str;
description = ''
Top level hostname
'';
};
serverName = lib.mkOption {
default = "localhost";
type = lib.types.str;
description = ''
Server name where Caddy is
'';
};
};
};
config = lib.mkIf cfg.enable {
my.virtualisation.podman.enable = true;
systemd.services.pod-download = {
description = "Start podman 'download' pod";
wants = [ "network-online.target" ];
after = [ "network-online.target" ];
requiredBy = [
"podman-jackett.service"
"podman-radarr.service"
"podman-sabnzbd.service"
"podman-sonarr.service"
];
unitConfig = {
RequiresMountsFor = "/run/containers";
};
serviceConfig = {
Type = "oneshot";
# - 7878: Radarr
# - 8080: Sabnzbd
# - 8989: Sonarr
# - 9117: Jackett
# - 9696: Prowlarr
ExecStart = "-${pkgs.podman}/bin/podman pod create -p 9117:9117 -p 7878:7878 -p 8080:8080 -p 8989:8989 -p 9696:9696 download";
};
path = [ pkgs.podman ];
};
virtualisation.oci-containers.containers = {
my-pod = {
image = "k8s.gcr.io/pause:3.9";
extraOptions = [
"--pod=new:my-pod"
"--publish=8081:80" # Expose port 80 in the pod as 8080 on the host
"--publish=8082:82" # Expose port 82 in the pod as 8082 on the host
"--publish=83:9117" # Expose port 9117 in the pod as 83 on the host
];
};
jackett = {
image = "linuxserver/jackett";
autoStart = true;
extraOptions = [ "--pod=my-pod" ];
volumes = [
"jackett_config:/config"
"jackett_data:/data"
];
};
radarr = {
image = "linuxserver/radarr";
autoStart = true;
extraOptions = [ "--pod=download" ];
volumes = [
"radarr_config:/config"
"radarr_data:/data"
];
};
sabnzbd = {
image = "linuxserver/sabnzbd";
autoStart = true;
extraOptions = [ "--pod=download" ];
volumes = [
"sabnzbd_config:/config"
"sabnzbd_data:/data"
];
};
sonarr = {
image = "linuxserver/sonarr";
autoStart = true;
extraOptions = [ "--pod=download" ];
volumes = [
"sonarr_config:/config"
"sonarr_data:/data"
];
};
prowlarr = {
image = "linuxserver/prowlarr";
autoStart = true;
extraOptions = [ "--pod=download" ];
volumes = [ "prowlarr_config:/config" ];
};
};
services.caddy = lib.mkIf cfg.proxy.enable {
enable = true;
enableReload = false;
virtualHosts = {
"jackett.${cfg.proxy.hostName}".extraConfig = ''
reverse_proxy http://${cfg.proxy.serverName}:9117
'';
"radarr.${cfg.proxy.hostName}".extraConfig = ''
reverse_proxy http://${cfg.proxy.serverName}:7878
'';
"sabnzbd.${cfg.proxy.hostName}".extraConfig = ''
reverse_proxy http://${cfg.proxy.serverName}:8080
'';
"sonarr.${cfg.proxy.hostName}".extraConfig = ''
reverse_proxy http://${cfg.proxy.serverName}:8989
'';
};
};
};
}

View file

@ -5,10 +5,10 @@
...
}:
let
cfg = config.download-pod-old;
cfg = config.my.services.download-pod-old;
in
{
options.download-pod-old = {
options.my.services.download-pod-old = {
enable = lib.mkEnableOption "Enable download services module";
proxy = {
@ -43,7 +43,7 @@ in
};
config = lib.mkIf cfg.enable {
podman.enable = true;
my.virtualisation.podman.enable = true;
systemd.services.pod-download = {
description = "Start podman 'download' pod";

View file

@ -5,10 +5,33 @@
...
}:
let
cfg = config.download-pod;
cfg = config.my.services.download-pod;
containers = {
webserver = {
enable = true;
image = "nginx";
volumes = [
"aaa:/config"
"bbb:/data"
];
};
postgres = {
enable = false;
image = "postgres:13";
};
};
enabledContainers =
containers:
lib.mapAttrs (name: container: lib.removeAttrs container [ "enable" ]) (
lib.filterAttrs (name: container: container.enable) containers
);
in
{
options.download-pod = {
options.my.services.download-pod = {
enable = lib.mkEnableOption "Enable the download searcher stack";
proxy = {
@ -36,93 +59,69 @@ in
config = lib.mkIf cfg.enable {
podman.enable = true;
systemd.services.pod-download = {
description = "Start podman 'download' pod";
wants = [ "network-online.target" ];
after = [ "network-online.target" ];
requiredBy = [
"podman-jackett.service"
"podman-radarr.service"
"podman-sabnzbd.service"
"podman-sonarr.service"
];
unitConfig = {
RequiresMountsFor = "/run/containers";
my.virtualisation.podmanPods = {
mywebapp = {
name = "mywebapp";
ports = [
"9090:80"
"9443:443"
];
containers = enabledContainers containers;
};
serviceConfig = {
Type = "oneshot";
# - 7878: Radarr
# - 8080: Sabnzbd
# - 8989: Sonarr
# - 9117: Jackett
# - 9696: Prowlarr
ExecStart = "-${pkgs.podman}/bin/podman pod create -p 9117:9117 -p 7878:7878 -p 8080:8080 -p 8989:8989 -p 9696:9696 download";
};
path = [ pkgs.podman ];
};
virtualisation.oci-containers.containers = {
virtualisation.oci-containers.containers = enabledContainers containers;
my-pod = {
image = "k8s.gcr.io/pause:3.9";
extraOptions = [
"--pod=new:my-pod"
"--publish=8081:80" # Expose port 80 in the pod as 8080 on the host
"--publish=8082:82" # Expose port 82 in the pod as 8082 on the host
"--publish=83:9117" # Expose port 9117 in the pod as 83 on the host
];
};
# virtualisation.oci-containers.containers = {
jackett = {
image = "linuxserver/jackett";
autoStart = true;
extraOptions = [ "--pod=my-pod" ];
volumes = [
"jackett_config:/config"
"jackett_data:/data"
];
};
# jackett = {
# image = "linuxserver/jackett";
# autoStart = true;
# extraOptions = [ "--pod=my-pod" ];
# volumes = [
# "jackett_config:/config"
# "jackett_data:/data"
# ];
# };
radarr = {
image = "linuxserver/radarr";
autoStart = true;
extraOptions = [ "--pod=download" ];
volumes = [
"radarr_config:/config"
"radarr_data:/data"
];
};
# radarr = {
# image = "linuxserver/radarr";
# autoStart = true;
# extraOptions = [ "--pod=download" ];
# volumes = [
# "radarr_config:/config"
# "radarr_data:/data"
# ];
# };
sabnzbd = {
image = "linuxserver/sabnzbd";
autoStart = true;
extraOptions = [ "--pod=download" ];
volumes = [
"sabnzbd_config:/config"
"sabnzbd_data:/data"
];
};
# sabnzbd = {
# image = "linuxserver/sabnzbd";
# autoStart = true;
# extraOptions = [ "--pod=download" ];
# volumes = [
# "sabnzbd_config:/config"
# "sabnzbd_data:/data"
# ];
# };
sonarr = {
image = "linuxserver/sonarr";
autoStart = true;
extraOptions = [ "--pod=download" ];
volumes = [
"sonarr_config:/config"
"sonarr_data:/data"
];
};
# sonarr = {
# image = "linuxserver/sonarr";
# autoStart = true;
# extraOptions = [ "--pod=download" ];
# volumes = [
# "sonarr_config:/config"
# "sonarr_data:/data"
# ];
# };
prowlarr = {
image = "linuxserver/prowlarr";
autoStart = true;
extraOptions = [ "--pod=download" ];
volumes = [ "prowlarr_config:/config" ];
};
# prowlarr = {
# image = "linuxserver/prowlarr";
# autoStart = true;
# extraOptions = [ "--pod=download" ];
# volumes = [ "prowlarr_config:/config" ];
# };
};
# };
services.caddy = lib.mkIf cfg.proxy.enable {
enable = true;

View file

@ -5,15 +5,15 @@
...
}:
let
cfg = config.nextcloud-pd;
cfg = config.my.services.nextcloud-pd;
in
{
options.nextcloud-pd = {
options.my.services.nextcloud-pd = {
enable = lib.mkEnableOption "Enable Nextcloud module";
};
config = lib.mkIf cfg.enable {
podman.enable = true;
my.virtualisation.podman.enable = true;
virtualisation.oci-containers.containers = { };

View file

@ -8,7 +8,7 @@
with lib;
let
cfg = config.services.rutorrent;
cfg = config.my.services.rutorrent;
rutorrentPkgs = import ../packages/rutorrent.nix {
inherit pkgs;
@ -44,7 +44,7 @@ let
in
{
options = {
options.my = {
services.rutorrent = {
enable = mkEnableOption "ruTorrent";