Merge pull request #240119 from josephst/recyclarr

This commit is contained in:
Janik 2023-07-13 23:44:37 +02:00 committed by GitHub
commit 406fa0477c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 142 additions and 0 deletions

View File

@ -8102,6 +8102,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";

View File

@ -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" ];
};
}

View File

@ -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"

View File

@ -6095,6 +6095,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 {