diff --git a/README.md b/README.md index 3018fed..6a5dcf0 100644 --- a/README.md +++ b/README.md @@ -4,17 +4,17 @@ * [flake.nix](./flake.nix) ### Desktop -* [configuration.nix](./configuration.nix) -* [hardware-configuration.nix](./hardware-configuration.nix) -* [home.nix](./home.nix) -* [impermenance.nix](./impermanence.nix) +* [configuration.nix](./hosts/desktop/configuration.nix) +* [hardware-configuration.nix](./hosts/desktop/hardware-configuration.nix) +* [home.nix](./hosts/desktop/home.nix) +* [impermenance.nix](./hosts/desktop/impermanence.nix) * cachix - * [cachix.nix](./cachix.nix) + * [cachix.nix](./cachix/cachix.nix) * [nix-community.nix](./cachix/nix-community.nix) ### NAS -* [configuration.nix](./configuration-nas.nix) -* [hardware-configuration.nix](./hardware-configuration-nas.nix) +* [configuration.nix](./hosts/nas/configuration.nix) +* [hardware-configuration.nix](./hosts/nas/hardware-configuration.nix) * [samba](./nas-samba/samba.nix) * nas-apps * [swag](./nas-apps/swag.nix) @@ -27,6 +27,6 @@ * [radarr](./nas-apps/radarr.nix) ### Raspberry Pi 4 -* [configuration.nix](./configuration-pi4.nix) -* [hardware-configuration.nix](./hardware-configuration-pi4.nix) -* [docker](./docker-pi4.nix) \ No newline at end of file +* [configuration.nix](./hosts/pi4/configuration.nix) +* [hardware-configuration.nix](./hosts/pi4/hardware-configuration.nix) +* [docker](./hosts/pi4/docker-pi4.nix) \ No newline at end of file diff --git a/cachix.nix b/cachix/cachix.nix similarity index 100% rename from cachix.nix rename to cachix/cachix.nix diff --git a/configuration.nix b/hosts/desktop/configuration.nix similarity index 99% rename from configuration.nix rename to hosts/desktop/configuration.nix index 1179256..85b6ef6 100644 --- a/configuration.nix +++ b/hosts/desktop/configuration.nix @@ -23,7 +23,7 @@ in imports = [ # Include the results of the hardware scan. ./hardware-configuration.nix - ./cachix.nix + ./cachix/cachix.nix ]; # Enable nix flakes and nix-command tools diff --git a/hardware-configuration.nix b/hosts/desktop/hardware-configuration.nix similarity index 100% rename from hardware-configuration.nix rename to hosts/desktop/hardware-configuration.nix diff --git a/home.nix b/hosts/desktop/home.nix similarity index 100% rename from home.nix rename to hosts/desktop/home.nix diff --git a/impermanence.nix b/hosts/desktop/impermanence.nix similarity index 100% rename from impermanence.nix rename to hosts/desktop/impermanence.nix diff --git a/configuration-nas.nix b/hosts/nas/configuration.nix similarity index 94% rename from configuration-nas.nix rename to hosts/nas/configuration.nix index e2018d5..5770947 100644 --- a/configuration-nas.nix +++ b/hosts/nas/configuration.nix @@ -12,22 +12,38 @@ in { imports = [ # Include the results of the hardware scan. - ./hardware-configuration-nas.nix - ./nas-samba/samba.nix - ./nas-apps/swag.nix - ./nas-apps/jellyfin.nix - ./nas-apps/sonarr.nix - ./nas-apps/radarr.nix - ./nas-apps/sabnzbd.nix - ./nas-apps/mariadb.nix - ./nas-apps/nextcloud.nix - ./nas-apps/collabora.nix - ./nas-apps/jellyseerr.nix + ./hardware-configuration.nix + ../../nas-samba/samba.nix + ../../nas-apps/nas-apps.nix ]; # Enable nix flakes and nix-command tools nix.settings.experimental-features = [ "nix-command" "flakes" ]; + nas-apps = { + jellyfin.enable = true; + + jellyseerr.enable = true; + + sabnzbd.enable = true; + + radarr.enable = true; + + sonarr.enable = true; + + collabora.enable = true; + + mariadb.enable = true; + + nextcloud = { + enable = true; + httpPort = "9980"; + httpsPort = "9443"; + }; + + swag.enable = true; + }; + # Configure bootloader with lanzaboot and secureboot boot = { loader = { @@ -216,8 +232,8 @@ in enable = true; allowPing = true; extraCommands = ''iptables -t raw -A OUTPUT -p udp -m udp --dport 137 -j CT --helper netbios-ns''; # TODO is this needed? - allowedTCPPorts = [ 80 443 61208 ]; - allowedUDPPorts = [ 80 443 61208 ]; + allowedTCPPorts = [ 61208 ]; + allowedUDPPorts = [ 61208 ]; }; }; diff --git a/hardware-configuration-nas.nix b/hosts/nas/hardware-configuration.nix similarity index 100% rename from hardware-configuration-nas.nix rename to hosts/nas/hardware-configuration.nix diff --git a/configuration-pi4.nix b/hosts/pi4/configuration.nix similarity index 100% rename from configuration-pi4.nix rename to hosts/pi4/configuration.nix diff --git a/docker-pi4.nix b/hosts/pi4/docker-pi4.nix similarity index 100% rename from docker-pi4.nix rename to hosts/pi4/docker-pi4.nix diff --git a/hardware-configuration-pi4.nix b/hosts/pi4/hardware-configuration.nix similarity index 100% rename from hardware-configuration-pi4.nix rename to hosts/pi4/hardware-configuration.nix diff --git a/nas-apps/collabora.nix b/nas-apps/collabora.nix index 51e0d9a..83e1c0e 100644 --- a/nas-apps/collabora.nix +++ b/nas-apps/collabora.nix @@ -1,9 +1,61 @@ -{ config, pkgs, ... }: -{ - # code - virtualisation.oci-containers.containers."collabora" = { - autoStart = true; - image = "collabora/code"; - ports = [ "9980:9980" ]; +{ lib, pkgs, config, ... }: +with lib; +let + cfg = config.nas-apps.collabora; +in { + options.nas-apps.collabora = { + enable = mkEnableOption "collabora docker service"; + + autoStart = mkOption { + type = types.bool; + default = true; + }; + + port = mkOption { + type = types.str; + default = "9980"; + }; + + name = mkOption { + type = types.str; + default = "collabora"; + }; + + image = mkOption { + type = types.str; + default = "collabora/code"; + }; + + puid = mkOption { + type = types.str; + default = "911"; + }; + + pgid = mkOption { + type = types.str; + default = "1000"; + }; + + timeZone = mkOption { + type = types.str; + default = "America/Chicago"; + }; + + }; + + config = mkIf cfg.enable { + virtualisation.oci-containers.containers."${cfg.name}" = { + autoStart = cfg.autoStart; + image = cfg.image; + ports = [ "${cfg.port}:9980" ]; + volumes = [ + # ... + ]; + environment = { + PUID = cfg.puid; + PGID = cfg.pgid; + TZ = cfg.timeZone; + }; + }; }; } diff --git a/nas-apps/dashy.nix b/nas-apps/dashy.nix new file mode 100644 index 0000000..fe24d16 --- /dev/null +++ b/nas-apps/dashy.nix @@ -0,0 +1,17 @@ +{ config, pkgs, ... }: +{ + # dashy + virtualisation.oci-containers.containers."dashy" = { + autoStart = true; + image = " lissy93/dashy:latest"; + ports = [ "8888:80" ]; + volumes = [ + "/mnt/ssd/nix-app-data/dashy/conf.yaml:/app/public/conf.yaml" + ]; + environment = { + PUID = "911"; + PGID = "1000"; + TZ = "America/Chicago"; + }; + }; +} diff --git a/nas-apps/jellyfin.nix b/nas-apps/jellyfin.nix index 7aede21..7cdb846 100644 --- a/nas-apps/jellyfin.nix +++ b/nas-apps/jellyfin.nix @@ -1,67 +1,128 @@ -{ config, pkgs, ... }: +{ lib, pkgs, config, ... }: +with lib; +let + cfg = config.nas-apps.jellyfin; +in { + options.nas-apps.jellyfin = { + enable = mkEnableOption "jellyfin docker service"; + + autoStart = mkOption { + type = types.bool; + default = true; + }; -{ - # Jellyfin - # Nix - # environment.systemPackages = [ - # pkgs.jellyfin - # pkgs.jellyfin-web - # pkgs.jellyfin-ffmpeg - # ]; + port = mkOption { + type = types.str; + default = "8096"; + }; - # services.jellyfin = { - # enable = true; - # user = "911"; - # group = "1000"; - # # dataDir = "/mnt/Safe\ SSD/ssd_app_data/jellyfin/config"; # defaults to /var/lib/jellyfin and cannot be changed.... - # openFirewall = true; + name = mkOption { + type = types.str; + default = "jellyfin"; + }; - # }; + image = mkOption { + type = types.str; + default = "lscr.io/linuxserver/jellyfin"; + }; - # nix-docker - # virtualisation.oci-containers.containers."jellyfin" = { - # autoStart = true; - # image = "linuxserver/jellyfin"; - # cmd = [ "--gpus all" ]; - # volumes = [ - # "/mnt/Safe\ SSD/ssd_app_data/jellyfin/config:/config" - # "/mnt/Safe\ SSD/ssd_app_data/jellyfin/cache:/cache" - # "/mnt/Safe\ SSD/ssd_app_data/jellyfin/log:/log" - # "/mnt/Main\ Pool/Movies:/movies" - # "/mnt/Main\ Pool/TV:/tv" - # ]; - # ports = [ "8096:8096" ]; - # environment = { - # NVIDIA_VISIBLE_DEVICES = "all"; - # NVIDIA_DRIVER_CAPABILITIES = "compute,utility"; - # JELLYFIN_LOG_DIR = "/log"; - # PUID = "911"; - # PGID = "1000"; - # }; - # }; + configPath = mkOption { + type = types.str; + default = "/mnt/ssd/nix-app-data/jellyfin"; + }; + + moviesPath = mkOption { + type = types.str; + default = "/mnt/mainpool/Movies"; + }; + + tvPath = mkOption { + type = types.str; + default = "/mnt/mainpool/Tv"; + }; + + puid = mkOption { + type = types.str; + default = "911"; + }; + + pgid = mkOption { + type = types.str; + default = "1000"; + }; + + timeZone = mkOption { + type = types.str; + default = "America/Chicago"; + }; - # Manual - systemd.services.jellyfin-nvidia-docker = { - path = [ pkgs.bash pkgs.docker ]; - script = '' - set -e - exec docker run \ - --rm \ - --gpus all \ - --runtime=nvidia \ - --name=jellyfin \ - -e PUID=911 \ - -e PGID=1000 \ - -e TZ=America/Chicago \ - -e 'NVIDIA_DRIVER_CAPABILITIES'='all' \ - -e 'NVIDIA_VISIBLE_DEVICES'='all' \ - -p 8096:8096 \ - -v '/mnt/ssd/nix-app-data/jellyfin:/config' \ - -v '/mnt/mainpool/Movies:/data/movies' \ - -v '/mnt/mainpool/TV:/data/tv' \ - lscr.io/linuxserver/jellyfin:latest - ''; - wantedBy = [ "multi-user.target" ]; }; + config = mkIf cfg.enable { + + systemd.services.jellyfin-nvidia-docker = { + path = [ pkgs.bash pkgs.docker ]; + script = '' + set -e + exec docker run \ + --rm \ + --gpus all \ + --runtime=nvidia \ + --name=${cfg.name} \ + -e PUID=${cfg.puid} \ + -e PGID=${cfg.pgid} \ + -e TZ=${cfg.timeZone} \ + -e 'NVIDIA_DRIVER_CAPABILITIES'='all' \ + -e 'NVIDIA_VISIBLE_DEVICES'='all' \ + -p ${cfg.port}:8096 \ + -v '${cfg.configPath}:/config' \ + -v '${cfg.moviesPath}:/data/movies' \ + -v '${cfg.tvPath}:/data/tv' \ + ${cfg.image}:latest + ''; + wantedBy = [ "multi-user.target" ]; + }; + }; } +# { config, pkgs, ... }: + +# { +# # Jellyfin +# # Nix +# # environment.systemPackages = [ +# # pkgs.jellyfin +# # pkgs.jellyfin-web +# # pkgs.jellyfin-ffmpeg +# # ]; + +# # services.jellyfin = { +# # enable = true; +# # user = "911"; +# # group = "1000"; +# # # dataDir = "/mnt/Safe\ SSD/ssd_app_data/jellyfin/config"; # defaults to /var/lib/jellyfin and cannot be changed.... +# # openFirewall = true; + +# # }; + +# # nix-docker +# # virtualisation.oci-containers.containers."jellyfin" = { +# # autoStart = true; +# # image = "linuxserver/jellyfin"; +# # cmd = [ "--gpus all" ]; +# # volumes = [ +# # "/mnt/Safe\ SSD/ssd_app_data/jellyfin/config:/config" +# # "/mnt/Safe\ SSD/ssd_app_data/jellyfin/cache:/cache" +# # "/mnt/Safe\ SSD/ssd_app_data/jellyfin/log:/log" +# # "/mnt/Main\ Pool/Movies:/movies" +# # "/mnt/Main\ Pool/TV:/tv" +# # ]; +# # ports = [ "8096:8096" ]; +# # environment = { +# # NVIDIA_VISIBLE_DEVICES = "all"; +# # NVIDIA_DRIVER_CAPABILITIES = "compute,utility"; +# # JELLYFIN_LOG_DIR = "/log"; +# # PUID = "911"; +# # PGID = "1000"; +# # }; +# # }; +# } \ No newline at end of file diff --git a/nas-apps/jellyseerr.nix b/nas-apps/jellyseerr.nix index 66b929e..39cf566 100644 --- a/nas-apps/jellyseerr.nix +++ b/nas-apps/jellyseerr.nix @@ -1,17 +1,66 @@ -{ config, pkgs, ... }: -{ - # jellyseerr - virtualisation.oci-containers.containers."jellyseerr" = { - autoStart = true; - image = "fallenbagel/jellyseerr"; - ports = [ "5055:5055" ]; - volumes = [ - "/mnt/ssd/ssd_app_data/jellyseerr:/config" - ]; - environment = { - PUID = "911"; - PGID = "1000"; - TZ = "America/Chicago"; +{ lib, pkgs, config, ... }: +with lib; +let + cfg = config.nas-apps.jellyseerr; +in { + options.nas-apps.jellyseerr = { + enable = mkEnableOption "jellyseerr docker service"; + + autoStart = mkOption { + type = types.bool; + default = true; + }; + + port = mkOption { + type = types.str; + default = "5055"; + }; + + name = mkOption { + type = types.str; + default = "jellyseerr"; + }; + + image = mkOption { + type = types.str; + default = "fallenbagel/jellyseerr"; + }; + + configPath = mkOption { + type = types.str; + default = "/mnt/ssd/ssd_app_data/jellyseerr"; + }; + + puid = mkOption { + type = types.str; + default = "911"; + }; + + pgid = mkOption { + type = types.str; + default = "1000"; + }; + + timeZone = mkOption { + type = types.str; + default = "America/Chicago"; + }; + + }; + + config = mkIf cfg.enable { + virtualisation.oci-containers.containers."${cfg.name}" = { + autoStart = cfg.autoStart; + image = cfg.image; + ports = [ "${cfg.port}:5055" ]; + volumes = [ + "${cfg.configPath}:/config" + ]; + environment = { + PUID = cfg.puid; + PGID = cfg.pgid; + TZ = cfg.timeZone; + }; }; }; } diff --git a/nas-apps/mariadb.nix b/nas-apps/mariadb.nix index 217547a..65b64a6 100644 --- a/nas-apps/mariadb.nix +++ b/nas-apps/mariadb.nix @@ -1,21 +1,90 @@ -{ config, pkgs, ... }: -{ - # mariadb - virtualisation.oci-containers.containers."mariadb" = { - autoStart = true; - image = "linuxserver/mariadb"; - ports = [ "3306:3306" ]; - volumes = [ - "/mnt/ssd/mariadb:/config" - ]; - environment = { - PUID = "911"; - PGID = "1000"; - TZ = "America/Chicago"; - MYSQL_ROOT_PASSWORD = "BogieDudie1"; - MYSQL_DATABASE = "jallen_nextcloud"; - MYSQL_USER = "nextcloud"; - MYSQL_PASSWORD = "BogieDudie1"; +{ lib, pkgs, config, ... }: +with lib; +let + cfg = config.nas-apps.mariadb; +in { + options.nas-apps.mariadb = { + enable = mkEnableOption "mariadb docker service"; + + autoStart = mkOption { + type = types.bool; + default = true; + }; + + port = mkOption { + type = types.str; + default = "3306"; + }; + + name = mkOption { + type = types.str; + default = "mariadb"; + }; + + image = mkOption { + type = types.str; + default = "linuxserver/mariadb"; + }; + + configPath = mkOption { + type = types.str; + default = "/mnt/ssd/mariadb"; + }; + + puid = mkOption { + type = types.str; + default = "911"; + }; + + pgid = mkOption { + type = types.str; + default = "1000"; + }; + + timeZone = mkOption { + type = types.str; + default = "America/Chicago"; + }; + + rootPassword = mkOption { + type = types.str; + default = "BogieDudie1"; + }; + + databaseName = mkOption { + type = types.str; + default = "jallen_nextcloud"; + }; + + databaseUser = mkOption { + type = types.str; + default = "nextcloud"; + }; + + databasePassword = mkOption { + type = types.str; + default = "BogieDudie1"; + }; + + }; + + config = mkIf cfg.enable { + virtualisation.oci-containers.containers."${cfg.name}" = { + autoStart = cfg.autoStart; + image = cfg.image; + ports = [ "${cfg.port}:3306" ]; + volumes = [ + "${cfg.configPath}:/config" + ]; + environment = { + PUID = cfg.puid; + PGID = cfg.pgid; + TZ = cfg.timeZone; + MYSQL_ROOT_PASSWORD = cfg.rootPassword; + MYSQL_DATABASE = cfg.databaseName; + MYSQL_USER = cfg.databaseUser; + MYSQL_PASSWORD = cfg.databasePassword; + }; }; }; } diff --git a/nas-apps/nas-apps.nix b/nas-apps/nas-apps.nix new file mode 100644 index 0000000..50669d4 --- /dev/null +++ b/nas-apps/nas-apps.nix @@ -0,0 +1,16 @@ +{ ... }: +{ + imports = + [ + ./swag.nix + ./jellyfin.nix + ./sonarr.nix + ./radarr.nix + ./sabnzbd.nix + ./mariadb.nix + ./nextcloud.nix + ./collabora.nix + ./jellyseerr.nix + # ./dashy.nix + ]; +} \ No newline at end of file diff --git a/nas-apps/nextcloud.nix b/nas-apps/nextcloud.nix index d45774a..ef0d669 100644 --- a/nas-apps/nextcloud.nix +++ b/nas-apps/nextcloud.nix @@ -1,18 +1,77 @@ -{ config, pkgs, ... }: -{ - # nextcloud - virtualisation.oci-containers.containers."nextcloud" = { - autoStart = true; - image = "linuxserver/nextcloud"; - ports = [ "9443:443" "9880:80" ]; - volumes = [ - "/mnt/ssd/ssd_app_data/nextcloud:/config" - "/mnt/mainpool/Nextcloud:/data" - ]; - environment = { - PUID = "911"; - PGID = "1000"; - TZ = "America/Chicago"; +{ lib, pkgs, config, ... }: +with lib; +let + cfg = config.nas-apps.nextcloud; +in { + options.nas-apps.nextcloud = { + enable = mkEnableOption "nextcloud docker service"; + + autoStart = mkOption { + type = types.bool; + default = true; + }; + + httpPort = mkOption { + type = types.str; + default = "80"; + }; + + httpsPort = mkOption { + type = types.str; + default = "443"; + }; + + name = mkOption { + type = types.str; + default = "nextcloud"; + }; + + image = mkOption { + type = types.str; + default = "linuxserver/nextcloud"; + }; + + configPath = mkOption { + type = types.str; + default = "/mnt/ssd/ssd_app_data/nextcloud"; + }; + + dataPath = mkOption { + type = types.str; + default = "/mnt/mainpool/Nextcloud"; + }; + + puid = mkOption { + type = types.str; + default = "911"; + }; + + pgid = mkOption { + type = types.str; + default = "1000"; + }; + + timeZone = mkOption { + type = types.str; + default = "America/Chicago"; + }; + + }; + + config = mkIf cfg.enable { + virtualisation.oci-containers.containers."${cfg.name}" = { + autoStart = cfg.autoStart; + image = cfg.image; + ports = [ "${cfg.httpPort}:80" "${cfg.httpsPort}:443" ]; + volumes = [ + "${cfg.configPath}:/config" + "${cfg.dataPath}:/data" + ]; + environment = { + PUID = cfg.puid; + PGID = cfg.pgid; + TZ = cfg.timeZone; + }; }; }; } diff --git a/nas-apps/radarr.nix b/nas-apps/radarr.nix index 8d5eb66..2c6beed 100644 --- a/nas-apps/radarr.nix +++ b/nas-apps/radarr.nix @@ -1,19 +1,78 @@ -{ config, pkgs, ... }: -{ - # radarr - virtualisation.oci-containers.containers."radarr" = { - autoStart = true; - image = "linuxserver/radarr"; - ports = [ "7878:7878" ]; - volumes = [ - "/mnt/ssd/ssd_app_data/radarr:/config" - "/mnt/mainpool/Movies:/movies" - "/mnt/ssd/ssd_app_data/downloads:/downloads" - ]; - environment = { - PUID = "911"; - PGID = "1000"; - TZ = "America/Chicago"; +{ lib, pkgs, config, ... }: +with lib; +let + cfg = config.nas-apps.radarr; +in { + options.nas-apps.radarr = { + enable = mkEnableOption "radarr docker service"; + + autoStart = mkOption { + type = types.bool; + default = true; + }; + + port = mkOption { + type = types.str; + default = "7878"; + }; + + name = mkOption { + type = types.str; + default = "radarr"; + }; + + image = mkOption { + type = types.str; + default = "linuxserver/radarr"; + }; + + configPath = mkOption { + type = types.str; + default = "/mnt/ssd/ssd_app_data/radarr"; + }; + + moviesPath = mkOption { + type = types.str; + default = "/mnt/mainpool/Movies"; + }; + + downloadsPath = mkOption { + type = types.str; + default = "/mnt/ssd/ssd_app_data/downloads"; + }; + + puid = mkOption { + type = types.str; + default = "911"; + }; + + pgid = mkOption { + type = types.str; + default = "1000"; + }; + + timeZone = mkOption { + type = types.str; + default = "America/Chicago"; + }; + + }; + + config = mkIf cfg.enable { + virtualisation.oci-containers.containers."${cfg.name}" = { + autoStart = cfg.autoStart; + image = cfg.image; + ports = [ "${cfg.port}:7878" ]; + volumes = [ + "${cfg.configPath}:/config" + "${cfg.moviesPath}:/movies" + "${cfg.downloadsPath}:/downloads" + ]; + environment = { + PUID = cfg.puid; + PGID = cfg.pgid; + TZ = cfg.timeZone; + }; }; }; } diff --git a/nas-apps/sabnzbd.nix b/nas-apps/sabnzbd.nix index 4e912d6..67d298d 100644 --- a/nas-apps/sabnzbd.nix +++ b/nas-apps/sabnzbd.nix @@ -1,21 +1,90 @@ -{ config, pkgs, ... }: -{ - # sabnzbd - virtualisation.oci-containers.containers."sabnzbd" = { - autoStart = true; - image = "linuxserver/sabnzbd"; - ports = [ "8080:8080" ]; - volumes = [ - "/mnt/ssd/ssd_app_data/sabnzbd:/config" - "/mnt/mainpool/TV:/tv" - "/mnt/mainpool/Movies:/movies" - "/mnt/ssd/ssd_app_data/downloads:/downloads" - "/mnt/ssd/ssd_app_data/downloads-incomplete:/downloads-incomplete" - ]; - environment = { - PUID = "911"; - PGID = "1000"; - TZ = "America/Chicago"; +{ lib, pkgs, config, ... }: +with lib; +let + cfg = config.nas-apps.sabnzbd; +in { + options.nas-apps.sabnzbd = { + enable = mkEnableOption "sabnzbd docker service"; + + autoStart = mkOption { + type = types.bool; + default = true; + }; + + port = mkOption { + type = types.str; + default = "8080"; + }; + + name = mkOption { + type = types.str; + default = "sabnzbd"; + }; + + image = mkOption { + type = types.str; + default = "linuxserver/sabnzbd"; + }; + + configPath = mkOption { + type = types.str; + default = "/mnt/ssd/ssd_app_data/sabnzbd"; + }; + + moviesPath = mkOption { + type = types.str; + default = "/mnt/mainpool/Movies"; + }; + + tvPath = mkOption { + type = types.str; + default = "/mnt/mainpool/Tv"; + }; + + downloadsPath = mkOption { + type = types.str; + default = "/mnt/ssd/ssd_app_data/downloads"; + }; + + downloadsIncompletePath = mkOption { + type = types.str; + default = "/mnt/ssd/ssd_app_data/downloads-incomplete"; + }; + + puid = mkOption { + type = types.str; + default = "911"; + }; + + pgid = mkOption { + type = types.str; + default = "1000"; + }; + + timeZone = mkOption { + type = types.str; + default = "America/Chicago"; + }; + + }; + + config = mkIf cfg.enable { + virtualisation.oci-containers.containers."${cfg.name}" = { + autoStart = cfg.autoStart; + image = cfg.image; + ports = [ "${cfg.port}:8080" ]; + volumes = [ + "${cfg.configPath}:/config" + "${cfg.moviesPath}:/movies" + "${cfg.tvPath}:/tv" + "${cfg.downloadsPath}:/downloads" + "${cfg.downloadsIncompletePath}:/downloads-incomplete" + ]; + environment = { + PUID = cfg.puid; + PGID = cfg.pgid; + TZ = cfg.timeZone; + }; }; }; } diff --git a/nas-apps/sonarr.nix b/nas-apps/sonarr.nix index 7502168..ae81b28 100644 --- a/nas-apps/sonarr.nix +++ b/nas-apps/sonarr.nix @@ -1,19 +1,78 @@ -{ config, pkgs, ... }: -{ - # sonarr - virtualisation.oci-containers.containers."sonarr" = { - autoStart = true; - image = "linuxserver/sonarr"; - ports = [ "8989:8989" ]; - volumes = [ - "/mnt/ssd/ssd_app_data/sonarr:/config" - "/mnt/mainpool/TV:/tv" - "/mnt/ssd/ssd_app_data/downloads:/downloads" - ]; - environment = { - PUID = "911"; - PGID = "1000"; - TZ = "America/Chicago"; +{ lib, pkgs, config, ... }: +with lib; +let + cfg = config.nas-apps.sonarr; +in { + options.nas-apps.sonarr = { + enable = mkEnableOption "sonarr docker service"; + + autoStart = mkOption { + type = types.bool; + default = true; + }; + + port = mkOption { + type = types.str; + default = "8989"; + }; + + name = mkOption { + type = types.str; + default = "sonarr"; + }; + + image = mkOption { + type = types.str; + default = "linuxserver/sonarr"; + }; + + configPath = mkOption { + type = types.str; + default = "/mnt/ssd/ssd_app_data/sonarr"; + }; + + tvPath = mkOption { + type = types.str; + default = "/mnt/mainpool/TV"; + }; + + downloadsPath = mkOption { + type = types.str; + default = "/mnt/ssd/ssd_app_data/downloads"; + }; + + puid = mkOption { + type = types.str; + default = "911"; + }; + + pgid = mkOption { + type = types.str; + default = "1000"; + }; + + timeZone = mkOption { + type = types.str; + default = "America/Chicago"; + }; + + }; + + config = mkIf cfg.enable { + virtualisation.oci-containers.containers."${cfg.name}" = { + autoStart = cfg.autoStart; + image = cfg.image; + ports = [ "${cfg.port}:8989" ]; + volumes = [ + "${cfg.configPath}:/config" + "${cfg.tvPath}:/tv" + "${cfg.downloadsPath}:/downloads" + ]; + environment = { + PUID = cfg.puid; + PGID = cfg.pgid; + TZ = cfg.timeZone; + }; }; }; } diff --git a/nas-apps/swag.nix b/nas-apps/swag.nix index d3897e3..858d07b 100644 --- a/nas-apps/swag.nix +++ b/nas-apps/swag.nix @@ -1,21 +1,101 @@ -{ config, pkgs, ... }: -{ - # Swag - virtualisation.oci-containers.containers."swag" = { - autoStart = true; - image = "linuxserver/swag"; - ports = [ "80:80" "443:443" ]; - volumes = [ - "/mnt/ssd/ssd_app_data/swag:/config" - ]; - environment = { - PGID = "1000"; - PUID = "1000"; - EMAIL = "jalle008@proton.me"; - TZ = "America/Chicago"; - URL = "mjallen.dev"; - VALIDATION = "http"; - SUBDOMAINS = "jellyfin,hass,cloud,office,jellyseerr"; +{ lib, pkgs, config, ... }: +with lib; +let + cfg = config.nas-apps.swag; +in { + options.nas-apps.swag = { + enable = mkEnableOption "swag docker service"; + + autoStart = mkOption { + type = types.bool; + default = true; + }; + + httpPort = mkOption { + type = types.int; + default = 80; + }; + + httpsPort = mkOption { + type = types.int; + default = 443; + }; + + name = mkOption { + type = types.str; + default = "swag"; + }; + + image = mkOption { + type = types.str; + default = "linuxserver/swag"; + }; + + configPath = mkOption { + type = types.str; + default = "/mnt/ssd/ssd_app_data/swag"; + }; + + puid = mkOption { + type = types.str; + default = "911"; + }; + + pgid = mkOption { + type = types.str; + default = "1000"; + }; + + timeZone = mkOption { + type = types.str; + default = "America/Chicago"; + }; + + email = mkOption { + type = types.str; + default = "jalle008@proton.me"; + }; + + url = mkOption { + type = types.str; + default = "mjallen.dev"; + }; + + validation = mkOption { + type = types.str; + default = "http"; + }; + + subdomains = mkOption { + type = types.str; + default = "jellyfin,hass,cloud,office,jellyseerr"; + }; + + }; + + config = mkIf cfg.enable { + + networking.firewall = { + allowedTCPPorts = [ cfg.httpPort cfg.httpsPort ]; + allowedUDPPorts = [ cfg.httpPort cfg.httpsPort ]; + }; + + virtualisation.oci-containers.containers."${cfg.name}" = { + autoStart = cfg.autoStart; + image = cfg.image; + ports = [ "${toString cfg.httpPort}:80" "${toString cfg.httpsPort}:443" ]; + volumes = [ + "${cfg.configPath}:/config" + ]; + environment = { + PUID = cfg.puid; + PGID = cfg.pgid; + TZ = cfg.timeZone; + EMAIL = cfg.email; + URL = cfg.url; + VALIDATION = cfg.validation; + SUBDOMAINS = cfg.subdomains; + }; }; }; }