From c3767fd66656b494a3bf229a02563bd2090768d6 Mon Sep 17 00:00:00 2001 From: mjallen18 Date: Sat, 22 Jun 2024 21:02:18 -0500 Subject: [PATCH] tdarr --- hosts/nas/configuration.nix | 24 ++++++----- modules/apps/tdarr/default.nix | 44 +++++++++++++++++++ modules/apps/tdarr/options.nix | 77 ++++++++++++++++++++++++++++++++++ modules/default.nix | 1 + 4 files changed, 135 insertions(+), 11 deletions(-) create mode 100644 modules/apps/tdarr/default.nix create mode 100644 modules/apps/tdarr/options.nix diff --git a/hosts/nas/configuration.nix b/hosts/nas/configuration.nix index 4d13cdb..7fc9ea8 100644 --- a/hosts/nas/configuration.nix +++ b/hosts/nas/configuration.nix @@ -22,7 +22,7 @@ let ]; enableDisplayManager = false; # adding a flag cause nixos cant figure itself out and broke shit that cant be fixed - enableUps = true; + enableUps = false; in { imports = [ @@ -82,6 +82,8 @@ in swag.enable = true; + tdarr.enable = true; + vscode.enable = true; }; @@ -363,9 +365,9 @@ in # Configure environment environment = { - etc."nut/upsd.conf".source = /home/matt/upsd.conf; - etc."nut/upsd.users".source = /home/matt/upsd.users; - etc."nut/upsmon.conf".source = /home/matt/upsmon.conf; +# etc."nut/upsd.conf".source = /home/matt/upsd.conf; +# etc."nut/upsd.users".source = /home/matt/upsd.users; +# etc."nut/upsmon.conf".source = /home/matt/upsmon.conf; # List packages installed in system profile. To search, run: # $ nix search wget @@ -425,18 +427,18 @@ in monitor = "nasups@localhost 1 upsuser BogieDudie1 primary"; }; upsd = { - enable = true; + enable = enableUps; listen = { address = 0.0 0.0 0.0; port = 3493; }; }; - users = { - actions = [ "SET" ]; - instcmds = [ "ALL" ]; - upsmon = "primary"; - passwordFile = "/home/matt/ups.conf"; - }; +# users = { +# actions = [ "SET" ]; +# instcmds = [ "ALL" ]; +##* upsmon = "primary"; +# passwordFile = "/home/matt/ups.conf"; +# }; }; # Add UPS monitoring service diff --git a/modules/apps/tdarr/default.nix b/modules/apps/tdarr/default.nix new file mode 100644 index 0000000..7cac448 --- /dev/null +++ b/modules/apps/tdarr/default.nix @@ -0,0 +1,44 @@ +{ + lib, + pkgs, + config, + ... +}: +with lib; +let + cfg = config.nas-apps.tdarr; +in +{ + imports = [ ./options.nix ]; + + config = mkIf cfg.enable { + + virtualisation.oci-containers.containers.${cfg.name} = { + autoStart = true; + image = cfg.image; + extraOptions = [ "--device=nvidia.com/gpu=0" ]; + volumes = [ + "${cfg.configPath}:/app/configs" + "${cfg.serverPath}:/app/server" + "${cfg.logPath}:/app/logs" + "${cfg.transcodePath}:/temp" + "${cfg.moviesPath}:/data/movies" + "${cfg.tvPath}:/data/tv" + ]; + ports = [ "${cfg.serverPort}:8266" "${cfg.webUIPort}:8265" ]; + environment = { + serverPort = "8266"; + webUIPort = "8265"; + internalNode = "true"; + inContainer = "true"; + ffmpegVersion = "6"; + nodeName = "tdarr node"; + NVIDIA_VISIBLE_DEVICES = "all"; + NVIDIA_DRIVER_CAPABILITIES = "all"; + PUID = cfg.puid; + PGID = cfg.pgid; + TZ = cfg.timeZone; + }; + }; + }; +} diff --git a/modules/apps/tdarr/options.nix b/modules/apps/tdarr/options.nix new file mode 100644 index 0000000..8ead46c --- /dev/null +++ b/modules/apps/tdarr/options.nix @@ -0,0 +1,77 @@ +{ lib, ... }: +with lib; +{ + options.nas-apps.tdarr = { + enable = mkEnableOption "tdarr docker service"; + + autoStart = mkOption { + type = types.bool; + default = true; + }; + + serverPort = mkOption { + type = types.str; + default = "8266"; + }; + + webUIPort = mkOption { + type = types.str; + default = "8265"; + }; + + name = mkOption { + type = types.str; + default = "tdarr"; + }; + + image = mkOption { + type = types.str; + default = "ghcr.io/haveagitgat/tdarr"; + }; + + configPath = mkOption { + type = types.str; + default = "/home/admin/ssd/nix-app-data/tdarr/config"; + }; + + serverPath = mkOption { + type = types.str; + default = "/home/admin/ssd/nix-app-data/tdarr/server"; + }; + + logPath = mkOption { + type = types.str; + default = "/home/admin/ssd/nix-app-data/tdarr/logs"; + }; + + transcodePath = mkOption { + type = types.str; + default = "/home/admin/ssd/nix-app-data/tdarr/transcode"; + }; + + moviesPath = mkOption { + type = types.str; + default = "/home/admin/mainpool/Movies"; + }; + + tvPath = mkOption { + type = types.str; + default = "/home/admin/mainpool/TV"; + }; + + puid = mkOption { + type = types.str; + default = "911"; + }; + + pgid = mkOption { + type = types.str; + default = "1000"; + }; + + timeZone = mkOption { + type = types.str; + default = "America/Chicago"; + }; + }; +} diff --git a/modules/default.nix b/modules/default.nix index 90cbed4..8a09f52 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -20,6 +20,7 @@ ./apps/sabnzbd ./apps/sonarr ./apps/swag + ./apps/tdarr ./apps/vscode ]; }