From 185649c1bb769fa415a76f74eeee960d9b9c66f7 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Mon, 9 Oct 2023 00:00:56 +0000 Subject: [PATCH] Add smartrss --- flake.lock | 15 +++++++++++++++ flake.nix | 7 ++++++- modules/server/default.nix | 16 ++++++++++++++++ modules/server/smartrss.sh | 12 ++++++++++++ overlays/default.nix | 28 ++++++++++++++++++++++++++-- 5 files changed, 75 insertions(+), 3 deletions(-) create mode 100755 modules/server/smartrss.sh diff --git a/flake.lock b/flake.lock index dcbc60e..12b2cd6 100644 --- a/flake.lock +++ b/flake.lock @@ -69,6 +69,7 @@ "type": "github" } }, +<<<<<<< HEAD "flake-parts": { "inputs": { "nixpkgs-lib": [ @@ -204,6 +205,19 @@ "owner": "hercules-ci", "repo": "hercules-ci-effects", "type": "github" +======= + "flood": { + "flake": false, + "locked": { + "lastModified": 1696808821, + "narHash": "sha256-/9EEXVx+8IJuPMQY2bSvO93Iz1voGPTsJx7k4f5lk6o=", + "path": "/home/zoriya/projects/flood", + "type": "path" + }, + "original": { + "path": "/home/zoriya/projects/flood", + "type": "path" +>>>>>>> 8d135d2 (Add smartrss) } }, "home-manager": { @@ -356,6 +370,7 @@ "inputs": { "ags": "ags", "dwl-source": "dwl-source", + "flood": "flood", "home-manager": "home-manager", "impermanence": "impermanence", "neovim-nightly": "neovim-nightly", diff --git a/flake.nix b/flake.nix index 7816014..2cba730 100644 --- a/flake.nix +++ b/flake.nix @@ -23,6 +23,10 @@ url = "github:Aylur/ags"; inputs.nixpkgs.follows = "nixpkgs"; }; + flood = { + url = "/home/zoriya/projects/flood"; + flake = false; + }; }; outputs = { @@ -34,6 +38,7 @@ nixpkgs, tuxedo-nixos, dwl-source, + flood, ... } @ rawInput: let user = "zoriya"; @@ -50,7 +55,7 @@ # nur.nixosModules.nur { nixpkgs.overlays = [ - (import ./overlays {inherit dwl-source;}) + (import ./overlays {inherit dwl-source flood;}) # nur.overlay neovim-nightly.overlay ]; diff --git a/modules/server/default.nix b/modules/server/default.nix index c753ffc..b2e4c15 100644 --- a/modules/server/default.nix +++ b/modules/server/default.nix @@ -12,6 +12,21 @@ wrapProgram $out/bin/guesspath --prefix PATH : '${lib.makeBinPath propagatedBuildInputs}' "; }; + + smartrss = pkgs.stdenv.mkDerivation rec { + name = "smartrss"; + nativeBuildInputs = with pkgs; [makeWrapper]; + propagatedBuildInputs = with pkgs; [ + python3Packages.guessit + curl + jq + ]; + dontUnpack = true; + installPhase = " + install -Dm755 ${./smartrss.sh} $out/bin/smartrss + wrapProgram $out/bin/smartrss --prefix PATH : '${lib.makeBinPath propagatedBuildInputs}' + "; + }; in { # Make it use predictable interface names starting with eth0 boot.kernelParams = ["net.ifnames=0"]; @@ -107,6 +122,7 @@ in { wantedBy = ["multi-user.target"]; after = ["transmission.service"]; requires = ["transmission.service"]; + path = with pkgs; [mediainfo smartrss]; serviceConfig = { ExecStart = "${pkgs.flood}/bin/flood --rundir=/var/lib/flood --trurl=http://127.0.0.1:9091/transmission/rpc --truser '' --trpass ''"; User = "transmission"; diff --git a/modules/server/smartrss.sh b/modules/server/smartrss.sh new file mode 100755 index 0000000..7f4f59b --- /dev/null +++ b/modules/server/smartrss.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +set -e + +name=$(guessit "$1" -P "title") + +curl -s 'http://localhost:3000/api/torrents' -b $(cat /var/lib/flood/flood.cookiefile) | + jq '.torrents.[].directory' -r | + sed s@/mnt/kyoo/shows/@@ | + grep -qix "$name" + +echo "Downloading $1" +exit 80 diff --git a/overlays/default.nix b/overlays/default.nix index 425bb95..fcb7644 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -1,4 +1,7 @@ -{dwl-source}: self: super: let +{ + dwl-source, + flood, +}: self: super: let enableWayland = drv: bins: super.symlinkJoin { name = drv.name; @@ -18,7 +21,7 @@ in { .overrideAttrs (oldAttrs: { src = dwl-source; enableXWayland = true; - passthru.providedSessions = [ "dwl" ]; + passthru.providedSessions = ["dwl"]; patches = [ ../dwl_patches/autostart.patch ../dwl_patches/deck.patch @@ -43,6 +46,27 @@ in { ]; }); + flood = self.pkgs.buildNpmPackage { + pname = "flood"; + version = "4.7.0"; + + src = flood; + + npmDepsHash = "sha256-XmDnvq+ni5TOf3UQFc4JvGI3LiGpjbrLAocRvrW8qgk="; + + # The prepack script runs the build script, which we'd rather do in the build phase. + npmPackFlags = ["--ignore-scripts"]; + + NODE_OPTIONS = "--openssl-legacy-provider"; + + meta = with self.lib; { + description = "A modern web UI for various torrent clients with a Node.js backend and React frontend"; + homepage = "https://flood.js.org"; + license = licenses.gpl3Only; + maintainers = with maintainers; [winter]; + }; + }; + tuxedo-keyboard = super.callPackage ./tuxedo-keyboard {}; slack = enableWayland super.slack ["slack"]; discord = enableWayland super.discord ["discord" "Discord"];