From 26f2e8922c52b753abf8b2bfcd53c90eba0f9173 Mon Sep 17 00:00:00 2001 From: Joseph Stahl <1269177+josephst@users.noreply.github.com> Date: Tue, 27 Jun 2023 19:58:57 -0400 Subject: [PATCH 1/2] recyclarr: init at 5.1.0 --- pkgs/tools/video/recyclarr/default.nix | 88 ++++++++++++++++++++++++++ pkgs/tools/video/recyclarr/update.sh | 46 ++++++++++++++ pkgs/top-level/all-packages.nix | 2 + 3 files changed, 136 insertions(+) create mode 100644 pkgs/tools/video/recyclarr/default.nix create mode 100755 pkgs/tools/video/recyclarr/update.sh diff --git a/pkgs/tools/video/recyclarr/default.nix b/pkgs/tools/video/recyclarr/default.nix new file mode 100644 index 000000000000..1ad38489c555 --- /dev/null +++ b/pkgs/tools/video/recyclarr/default.nix @@ -0,0 +1,88 @@ +{ lib +, stdenv +, fetchurl +, makeWrapper +, autoPatchelfHook +, fixDarwinDylibNames +, darwin +, recyclarr +, git +, icu +, testers +, zlib +}: +let + os = + if stdenv.isDarwin + then "osx" + else "linux"; + + arch = { + x86_64-linux = "x64"; + aarch64-linux = "arm64"; + x86_64-darwin = "x64"; + aarch64-darwin = "arm64"; + }."${stdenv.hostPlatform.system}" + or (throw "Unsupported system: ${stdenv.hostPlatform.system}"); + + hash = { + x64-linux_hash = "sha256-aEcinTJlO++rTeyqGJea0TWtleH6fyooA8RhT0Qj24c="; + arm64-linux_hash = "sha256-9Gyk09zAGzahP8FCGxj037vaK8h++3M5R2Qqop99Gs4="; + x64-osx_hash = "sha256-c87eOZBz+RtbIi+dlXKKVMyPI8JqYDuiaL4xOkDRFn0="; + arm64-osx_hash = "sha256-zSHgLXRDB6UA7V0LFgLq9ChqB40IHIJJxRqAYyVFlB8="; + }."${arch}-${os}_hash"; + + libPath = { + osx = "DYLD_LIBRARY_PATH : ${lib.makeLibraryPath [darwin.ICU zlib]}"; + linux = "LD_LIBRARY_PATH : ${lib.makeLibraryPath [icu zlib]}"; + }."${os}"; + +in +stdenv.mkDerivation rec { + pname = "recyclarr"; + version = "5.1.0"; + + src = fetchurl { + url = "https://github.com/recyclarr/recyclarr/releases/download/v${version}/recyclarr-${os}-${arch}.tar.xz"; + inherit hash; + }; + + sourceRoot = "."; + + nativeBuildInputs = [ makeWrapper ] + ++ lib.optional stdenv.isLinux autoPatchelfHook + ++ lib.optional stdenv.isDarwin fixDarwinDylibNames; + buildInputs = [ icu zlib ]; + + installPhase = '' + runHook preInstall + + install -Dm755 recyclarr -t $out/bin + + runHook postInstall + ''; + + postInstall = '' + wrapProgram $out/bin/recyclarr \ + --prefix PATH : ${lib.makeBinPath [git]} \ + --prefix ${libPath} + ''; + + dontStrip = true; # stripping messes up dotnet single-file deployment + + passthru = { + updateScript = ./update.sh; + tests.version = testers.testVersion { + package = recyclarr; + }; + }; + + meta = with lib; { + description = "Automatically sync TRaSH guides to your Sonarr and Radarr instances"; + homepage = "https://recyclarr.dev/"; + changelog = "https://github.com/recyclarr/recyclarr/releases/tag/v${version}"; + license = licenses.mit; + maintainers = with maintainers; [ josephst ]; + platforms = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; + }; +} diff --git a/pkgs/tools/video/recyclarr/update.sh b/pkgs/tools/video/recyclarr/update.sh new file mode 100755 index 000000000000..83942439cc28 --- /dev/null +++ b/pkgs/tools/video/recyclarr/update.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env nix-shell +#!nix-shell -I nixpkgs=./. -i bash -p curl jq common-updater-scripts gnused nix coreutils +#shellcheck shell=bash + +set -euo pipefail + +latestVersion=$(curl -s ${GITHUB_TOKEN:+ -H "Authorization: Bearer $GITHUB_TOKEN"} https://api.github.com/repos/recyclarr/recyclarr/releases?per_page=1 \ + | jq -r ".[0].tag_name" \ + | sed 's/^v//') +currentVersion=$(nix-instantiate --eval -E "with import ./. {}; recyclarr.version or (lib.getVersion recyclarr)" | tr -d '"') + +if [[ "$currentVersion" == "$latestVersion" ]]; then + echo "recyclarr is up-to-date: $currentVersion" + exit 0 +fi + +function get_hash() { + local os=$1 + local arch=$2 + local version=$3 + + local pkg_hash=$(nix-prefetch-url --type sha256 \ + https://github.com/recyclarr/recyclarr/releases/download/v"${version}"/recyclarr-"${os}"-"${arch}".tar.xz) + nix hash to-sri "sha256:$pkg_hash" +} + +# aarch64-darwin +# reset version first so that all platforms are always updated and in sync +update-source-version recyclarr 0 "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=" --system="aarch64-darwin" +update-source-version recyclarr "$latestVersion" $(get_hash osx arm64 "$latestVersion") --system="aarch64-darwin" + +# x86_64-darwin +# reset version first so that all platforms are always updated and in sync +update-source-version recyclarr 0 "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=" --system="x86_64-darwin" +update-source-version recyclarr "$latestVersion" $(get_hash osx x64 "$latestVersion") --system="x86_64-darwin" + +# aarch64-linux +# reset version first so that all platforms are always updated and in sync +update-source-version recyclarr 0 "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=" --system="aarch64-linux" +update-source-version recyclarr "$latestVersion" $(get_hash linux arm64 "$latestVersion") --system="aarch64-linux" + +# x86_64-linux +# reset version first so that all platforms are always updated and in sync +update-source-version recyclarr 0 "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=" --system="x86_64-linux" +update-source-version recyclarr "$latestVersion" $(get_hash linux x64 "$latestVersion") --system="x86_64-linux" + diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 1be627caecdb..a94dcc2f42d6 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -6091,6 +6091,8 @@ with pkgs; replay-sorcery = callPackage ../tools/video/replay-sorcery { }; + recyclarr = callPackage ../tools/video/recyclarr { }; + tsduck = callPackage ../tools/video/tsduck { }; ripasso-cursive = callPackage ../tools/security/ripasso/cursive.nix { From 2868e85d93d6a60fdfd64031bcaf82f313553b80 Mon Sep 17 00:00:00 2001 From: Joseph Stahl <1269177+josephst@users.noreply.github.com> Date: Tue, 27 Jun 2023 19:59:04 -0400 Subject: [PATCH 2/2] maintainers: add josephst --- maintainers/maintainer-list.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/maintainers/maintainer-list.nix b/maintainers/maintainer-list.nix index 2b1df9ae0b31..917685fde608 100644 --- a/maintainers/maintainer-list.nix +++ b/maintainers/maintainer-list.nix @@ -8090,6 +8090,12 @@ email = "j.loos@posteo.net"; githubId = 57965027; }; + josephst = { + name = "Joseph Stahl"; + email = "hello@josephstahl.com"; + github = "josephst"; + githubId = 1269177; + }; joshniemela = { name = "Joshua Niemelä"; email = "josh@jniemela.dk";