From 56b1c6c29df01079d402380ee32266fdd40f586d Mon Sep 17 00:00:00 2001 From: Ingolf Wagner Date: Thu, 4 May 2023 20:59:26 +0200 Subject: [PATCH] add tdarr --- nixos/machines/chungus/configuration.nix | 4 +- nixos/machines/chungus/sync-script.nix | 46 ++++++++-------- nixos/machines/chungus/sync-torrent.nix | 1 + nixos/machines/chungus/tdarr.nix | 69 ++++++++++++++++++++++++ 4 files changed, 96 insertions(+), 24 deletions(-) create mode 100644 nixos/machines/chungus/tdarr.nix diff --git a/nixos/machines/chungus/configuration.nix b/nixos/machines/chungus/configuration.nix index 4cf6d86..e8cefd9 100644 --- a/nixos/machines/chungus/configuration.nix +++ b/nixos/machines/chungus/configuration.nix @@ -17,7 +17,10 @@ #./borg.nix #./taskwarrior-pushover.nix + + ./tdarr.nix #./jellyfin.nix + #./wireguard.nix # logging @@ -28,7 +31,6 @@ ./telegraf.nix #./home-display.nix - #./tdarr.nix ./rbackup.nix ./sync-torrent.nix diff --git a/nixos/machines/chungus/sync-script.nix b/nixos/machines/chungus/sync-script.nix index d6be10a..6765baf 100644 --- a/nixos/machines/chungus/sync-script.nix +++ b/nixos/machines/chungus/sync-script.nix @@ -10,34 +10,34 @@ # # -{pkgs, ...}: +{ pkgs, ... }: { - environment.systemPackages = [ + environment.systemPackages = [ (pkgs.writers.writeBashBin "torrent-sync" '' - set -e - set -x + set -e + set -x - file_folder=$( realpath "$1" ) - folder=$( dirname "$file_folder" ) - file=$( basename "$file_folder" ) + file_folder=$( realpath "$1" ) + folder=$( dirname "$file_folder" ) + file=$( basename "$file_folder" ) - pushd "$folder" - ${pkgs.transmission}/bin/transmission-create \ - -t udp://robi.private:6969/announce \ - -o ~/last.torrent \ - "$file" - popd + pushd "$folder" + ${pkgs.transmission}/bin/transmission-create \ + -t udp://robi.private:6969/announce \ + -o ~/last.torrent \ + "$file" + popd - ${pkgs.transmission}/bin/transmission-remote \ - sync.chungus.private:80 \ - -a ~/last.torrent \ - --download-dir "$folder" + ${pkgs.transmission}/bin/transmission-remote \ + sync.chungus.private:80 \ + -a ~/last.torrent \ + --download-dir "$folder" - ${pkgs.transmission}/bin/transmission-remote \ - sync.robi.private:80 \ - -a ~/last.torrent \ - --download-dir "$folder" + ${pkgs.transmission}/bin/transmission-remote \ + sync.robi.private:80 \ + -a ~/last.torrent \ + --download-dir "$folder" '') - ]; -} \ No newline at end of file + ]; +} diff --git a/nixos/machines/chungus/sync-torrent.nix b/nixos/machines/chungus/sync-torrent.nix index 332c7f3..19e6503 100644 --- a/nixos/machines/chungus/sync-torrent.nix +++ b/nixos/machines/chungus/sync-torrent.nix @@ -31,6 +31,7 @@ in services.transmission = { enable = true; + settings = { download-dir = "/media"; incomplete-dir = "/var/lib/transmission/incomplete"; # todo put this somewhere with frequent snapshots but low keep. diff --git a/nixos/machines/chungus/tdarr.nix b/nixos/machines/chungus/tdarr.nix new file mode 100644 index 0000000..df59836 --- /dev/null +++ b/nixos/machines/chungus/tdarr.nix @@ -0,0 +1,69 @@ +{ config, lib, pkgs, ... }: +{ + + # To set password: + # nix-shell -p samba --run "smbpasswd -a media" + custom.samba-share.enable = true; + custom.samba-share.private.media = { + folder = "/media"; + users = "media"; + }; + + users.groups."media".gid = config.ids.gids.transmission; + users.users."media" = { + uid = config.ids.uids.transmission; + group = "media"; + }; + + services.permown."/media" = { + owner = "media"; + group = "media"; + }; + + # https://docs.tdarr.io/docs/installation/docker/run-compose + virtualisation.oci-containers = { + #backend = "podman"; + containers.tdarr = { + volumes = [ + "/srv/tdarr/server:/app/server" + "/srv/tdarr/configs:/app/configs" + "/srv/tdarr/logs:/app/logs" + "/srv/tdarr/transcode_cache:/temp" + "/media:/media" + ]; + environment = { + serverIP = "0.0.0.0"; + serverPort = "8266"; + webUIPort = "8265"; + internalNode = "false"; + inContainer = "true"; + nodeName = "ServerNode"; + TZ = "Europe/London"; + PUID = toString config.ids.uids.transmission; + PGID = toString config.ids.gids.transmission; + }; + ports = [ + "8265:8265" # WebUI + "8266:8266" # server port + ]; + image = "ghcr.io/haveagitgat/tdarr:latest"; # Warning: if the tag does not change, the image will not be updated + extraOptions = [ "--network=bridge" ]; + }; + }; + + networking.firewall.allowedTCPPorts = [ 8266 ]; + networking.firewall.allowedUDPPorts = [ 8266 ]; + + services.nginx.virtualHosts."tdarr.${config.networking.hostName}.private" = { + serverAliases = [ "tdarr.${config.networking.hostName}" ]; + extraConfig = '' + allow ${config.tinc.private.subnet}; + deny all; + ''; + locations."/" = { + proxyPass = "http://localhost:8265"; + proxyWebsockets = true; + }; + }; + +}