From 840c7a183c7b8efe8b502a30ae6b2ffe5df97e3d Mon Sep 17 00:00:00 2001 From: mjallen18 Date: Tue, 14 May 2024 11:21:06 -0500 Subject: [PATCH] update nas docker stuff --- hosts/nas/configuration.nix | 61 ++++++++++++++++++++++---------- modules/apps/deluge/default.nix | 38 ++++++++++++++++++++ modules/apps/deluge/options.nix | 52 +++++++++++++++++++++++++++ modules/apps/jackett/default.nix | 23 ++++++++++++ modules/apps/jackett/options.nix | 51 ++++++++++++++++++++++++++ modules/default.nix | 3 +- 6 files changed, 208 insertions(+), 20 deletions(-) create mode 100644 modules/apps/deluge/default.nix create mode 100644 modules/apps/deluge/options.nix create mode 100644 modules/apps/jackett/default.nix create mode 100644 modules/apps/jackett/options.nix diff --git a/hosts/nas/configuration.nix b/hosts/nas/configuration.nix index ce66ad2..af8338f 100644 --- a/hosts/nas/configuration.nix +++ b/hosts/nas/configuration.nix @@ -11,7 +11,7 @@ let allowedPorts = [ 2342 3493 61208 9090 ]; enableDisplayManager = false; # adding a flag cause nixos cant figure itself out and broke shit that cant be fixed - enableUps = false; + enableUps = true; in { imports = [ # Include the results of the hardware scan. ./hardware-configuration.nix @@ -29,9 +29,11 @@ in { }; }; - + powerManagement.cpuFreqGovernor = "powersave"; nas-apps = { + jackett.enable = true; + jellyfin.enable = true; jellyseerr.enable = true; @@ -61,6 +63,8 @@ in { vscode.enable = true; swag.enable = true; + + deluge.enable = true; }; nas-samba = { @@ -127,7 +131,7 @@ in { # Override kernel to latest kernelPackages = config.boot.zfs.package.latestCompatibleLinuxPackages; - kernelParams = [ "nohibernate" ]; + kernelParams = [ "nohibernate" "amd_pstate=active" ]; consoleLogLevel = 3; bootspec.enable = true; @@ -332,6 +336,9 @@ in { packagekit gnome.gnome-packagekit unstable.nix-inspect + unstable.gpt4all + lm_sensors + htop ]; }; @@ -342,7 +349,7 @@ in { nix-ld.enable = true; }; - power.ups = { + power.ups.ups = { enable = enableUps; mode = "netserver"; ups."nasups" = { @@ -350,24 +357,40 @@ in { port = "auto"; description = "NAS UPS"; }; + upsmon = { + monitor = "nasups@localhost 1 upsuser BogieDudie1 primary"; + }; + upsd = { + enable = true; + listen = { + address = 0.0.0.0; + port = 3493; + }; + }; + users = { + actions = [ "SET" ]; + instcmds = [ "ALL" ]; + upsmon = "primary"; + passwordFile = "/root/ups.conf"; + }; }; # Add UPS monitoring service - # services.upsmon = { - # enable = true; - # # Configure UPS device - # device = "/dev/usb/hiddev1"; # Change this to your UPS device - # driver = "usbhid-ups"; # Change this if your UPS uses a different driver - # # Set UPS monitoring options - # options = { - # # NOTIFYCMD = "/path/to/notify-script.sh"; # Path to your notification script - # POLLFREQ = 5; - # POLLFREQALERT = 5; - # HOSTSYNC = "on"; - # DEADTIME = 15; - # FINALDELAY = 5; - # }; - # }; +# power.upsmon = { +# enable = true; +# # Configure UPS device +# device = "/dev/usb/hiddev1"; # Change this to your UPS device +# driver = "usbhid-ups"; # Change this if your UPS uses a different driver +# # Set UPS monitoring options +# options = { +# # NOTIFYCMD = "/path/to/notify-script.sh"; # Path to your notification script +# POLLFREQ = 5; +# POLLFREQALERT = 5; +# HOSTSYNC = "on"; +# DEADTIME = 15; +# FINALDELAY = 5; +# }; +# }; # Configure nixpkgs nixpkgs = { diff --git a/modules/apps/deluge/default.nix b/modules/apps/deluge/default.nix new file mode 100644 index 0000000..03b1b6f --- /dev/null +++ b/modules/apps/deluge/default.nix @@ -0,0 +1,38 @@ +{ lib, pkgs, config, ... }: +with lib; +let cfg = config.nas-apps.deluge; +in { + imports = [ ./options.nix ]; + + config = mkIf cfg.enable { + + systemd.services.deluge-docker = { + path = [ pkgs.bash pkgs.docker ]; + script = '' + set -e + exec docker run \ + --rm \ + --cap-add=NET_ADMIN \ + --name=${cfg.name} \ + -e PUID=${cfg.puid} \ + -e PGID=${cfg.pgid} \ + -e TZ=${cfg.timeZone} \ + -p 8112:8112 \ + -p 8118:8118 \ + -p 58846:58846 \ + -p 58946:58966 \ + -v '${cfg.configPath}:/config' \ + -v '${cfg.moviesPath}:/data/downloads' \ + -v '${cfg.tvPath}:/data/downloads-icomplete' \ + -v /etc/localtime:/etc/localtime:ro \ + -e VPN_ENABLED=yes \ + -e VPN_PROV=custom \ + -e VPN_CLIENT=openvpn \ + -e LAN_NETWORK=10.0.1.0/24 \ + -e NAME_SERVERS=1.1.1.1 \ + ${cfg.image}:latest + ''; + wantedBy = [ "multi-user.target" ]; + }; + }; +} diff --git a/modules/apps/deluge/options.nix b/modules/apps/deluge/options.nix new file mode 100644 index 0000000..609f29d --- /dev/null +++ b/modules/apps/deluge/options.nix @@ -0,0 +1,52 @@ +{ lib, ... }: +with lib; { + options.nas-apps.deluge = { + enable = mkEnableOption "deluge docker service"; + + autoStart = mkOption { + type = types.bool; + default = true; + }; + + name = mkOption { + type = types.str; + default = "deluge"; + }; + + image = mkOption { + type = types.str; + default = "binhex/arch-delugevpn"; + }; + + configPath = mkOption { + type = types.str; + default = "/mnt/ssd/nix-app-data/deluge"; + }; + + moviesPath = mkOption { + type = types.str; + default = "/mnt/ssd/ssd_app_data/downloads"; + }; + + tvPath = mkOption { + type = types.str; + default = "/mnt/ssd/ssd_app_data/downloads-incomplete"; + }; + + puid = mkOption { + type = types.str; + default = "0"; + }; + + pgid = mkOption { + type = types.str; + default = "0"; + }; + + timeZone = mkOption { + type = types.str; + default = "America/Chicago"; + }; + + }; +} diff --git a/modules/apps/jackett/default.nix b/modules/apps/jackett/default.nix new file mode 100644 index 0000000..3c40209 --- /dev/null +++ b/modules/apps/jackett/default.nix @@ -0,0 +1,23 @@ +{ lib, pkgs, config, ... }: +with lib; +let cfg = config.nas-apps.jackett; +in { + imports = [ ./options.nix ]; + + config = mkIf cfg.enable { + virtualisation.oci-containers.containers."${cfg.name}" = { + autoStart = cfg.autoStart; + image = cfg.image; + ports = [ "${cfg.port}:9117" ]; + volumes = [ + "${cfg.configPath}:/config" + "${cfg.downloadsPath}:/downloads" + ]; + environment = { + PUID = cfg.puid; + PGID = cfg.pgid; + TZ = cfg.timeZone; + }; + }; + }; +} diff --git a/modules/apps/jackett/options.nix b/modules/apps/jackett/options.nix new file mode 100644 index 0000000..09c3ae9 --- /dev/null +++ b/modules/apps/jackett/options.nix @@ -0,0 +1,51 @@ +{ lib, ... }: +with lib; { + options.nas-apps.jackett = { + enable = mkEnableOption "jackett docker service"; + + autoStart = mkOption { + type = types.bool; + default = true; + }; + + port = mkOption { + type = types.str; + default = "9117"; + }; + + name = mkOption { + type = types.str; + default = "jackett"; + }; + + image = mkOption { + type = types.str; + default = "linuxserver/jackett"; + }; + + configPath = mkOption { + type = types.str; + default = "/mnt/ssd/nix-app-data/jackett"; + }; + + 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"; + }; + }; +} diff --git a/modules/default.nix b/modules/default.nix index 7608b17..cf89b49 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -2,10 +2,11 @@ imports = [ ./samba ./apps/collabora - # ./apps/dashy + ./apps/deluge ./apps/discover-wrapped ./apps/homarr ./apps/homepage + ./apps/jackett ./apps/jellyfin ./apps/jellyseerr ./apps/mariadb