From 36497c2fde743f300b54920901ae308d57cb2863 Mon Sep 17 00:00:00 2001 From: Andrei Pampu Date: Wed, 24 Mar 2021 10:18:33 +0200 Subject: [PATCH] radarr: 0.2.0.1504 -> 3.0.2.4552 Use dotnet core instead of mono, change license to gpl3Only, add test passthru and create update script --- pkgs/servers/radarr/default.nix | 39 ++++++++++++++++++++++-------- pkgs/servers/radarr/update.sh | 42 +++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+), 10 deletions(-) create mode 100755 pkgs/servers/radarr/update.sh diff --git a/pkgs/servers/radarr/default.nix b/pkgs/servers/radarr/default.nix index ae0195156276..47edb29723e3 100644 --- a/pkgs/servers/radarr/default.nix +++ b/pkgs/servers/radarr/default.nix @@ -1,12 +1,26 @@ -{ lib, stdenv, fetchurl, mono, libmediainfo, sqlite, curl, makeWrapper }: +{ lib, stdenv, fetchurl, mono, libmediainfo, sqlite, curl, makeWrapper, icu, dotnetCorePackages, openssl, nixosTests }: -stdenv.mkDerivation rec { +let + os = if stdenv.isDarwin then "osx" else "linux"; + arch = { + x86_64-linux = "x64"; + aarch64-linux = "arm64"; + x86_64-darwin = "x64"; + }."${stdenv.hostPlatform.system}" or (throw "Unsupported system: ${stdenv.hostPlatform.system}"); + + hash = { + x64-linux_hash = "sha256-bTh+Z5w5ZkL2iPteStqVcoFDGZIbpVjuXn20TZsfgtY="; + arm64-linux_hash = "sha256-aIzVSIRuGNiIFJPToXCQwYsbICKuPtwKATnQhkxvJuA="; + x64-osx_hash = "sha256-FxRSAJvRQya2x1kei6yRceGcyQ2mCaFveyeMGw0Jqw4="; + }."${arch}-${os}_hash"; + +in stdenv.mkDerivation rec { pname = "radarr"; - version = "0.2.0.1504"; + version = "3.0.2.4552"; src = fetchurl { - url = "https://github.com/Radarr/Radarr/releases/download/v${version}/Radarr.develop.${version}.linux.tar.gz"; - sha256 = "1h7pqn39vxd0vr1fwrnvfpxv5vhh4zcr0s8h0zvgplay2z6b6bvb"; + url = "https://github.com/Radarr/Radarr/releases/download/v${version}/Radarr.master.${version}.${os}-core-${arch}.tar.gz"; + sha256 = hash; }; nativeBuildInputs = [ makeWrapper ]; @@ -15,17 +29,22 @@ stdenv.mkDerivation rec { mkdir -p $out/{bin,share/${pname}-${version}} cp -r * $out/share/${pname}-${version}/. - makeWrapper "${mono}/bin/mono" $out/bin/Radarr \ - --add-flags "$out/share/${pname}-${version}/Radarr.exe" \ + makeWrapper "${dotnetCorePackages.netcore_3_1}/bin/dotnet" $out/bin/Radarr \ + --add-flags "$out/share/${pname}-${version}/Radarr.dll" \ --prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ - curl sqlite libmediainfo ]} + curl sqlite libmediainfo mono openssl icu ]} ''; + passthru = { + updateScript = ./update.sh; + tests.smoke-test = nixosTests.radarr; + }; + meta = with lib; { description = "A Usenet/BitTorrent movie downloader"; homepage = "https://radarr.video/"; - license = licenses.gpl3; + license = licenses.gpl3Only; maintainers = with maintainers; [ edwtjo purcell ]; - platforms = platforms.all; + platforms = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" ]; }; } diff --git a/pkgs/servers/radarr/update.sh b/pkgs/servers/radarr/update.sh new file mode 100755 index 000000000000..ad5364ec7218 --- /dev/null +++ b/pkgs/servers/radarr/update.sh @@ -0,0 +1,42 @@ +#!/usr/bin/env nix-shell +#!nix-shell -i bash -p curl nix-prefetch jq + +set -e + +dirname="$(dirname "$0")" + +updateHash() +{ + version=$1 + arch=$2 + os=$3 + + hashKey="${arch}-${os}_hash" + + url="https://github.com/Radarr/Radarr/releases/download/v$version/Radarr.master.$version.$os-core-$arch.tar.gz" + hash=$(nix-prefetch-url --type sha256 $url) + sriHash="$(nix to-sri --type sha256 $hash)" + + sed -i "s/$hashKey = \"[a-zA-Z0-9\/+-=]*\";/$hashKey = \"$sriHash\";/g" "$dirname/default.nix" +} + +updateVersion() +{ + sed -i "s/version = \"[0-9.]*\";/version = \"$1\";/g" "$dirname/default.nix" +} + +currentVersion=$(cd $dirname && nix eval --raw '(with import ../../.. {}; radarr.version)') + +latestTag=$(curl https://api.github.com/repos/Radarr/Radarr/releases/latest | jq -r ".tag_name") +latestVersion="$(expr $latestTag : 'v\(.*\)')" + +if [[ "$currentVersion" == "$latestVersion" ]]; then + echo "Radarr is up-to-date: ${currentVersion}" + exit 0 +fi + +updateVersion $latestVersion + +updateHash $latestVersion x64 linux +updateHash $latestVersion arm64 linux +updateHash $latestVersion x64 osx