Merge pull request #334009 from josephst/feat/recyclarr-from-source

This commit is contained in:
Sandro
2024-08-22 14:18:41 +02:00
committed by GitHub
7 changed files with 1343 additions and 124 deletions
@@ -0,0 +1,14 @@
diff --git a/Directory.Build.props b/Directory.Build.props
index af8e3b12..07dd1898 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -9,7 +9,7 @@
<RepositoryRoot>$(MSBuildThisFileDirectory)</RepositoryRoot>
<TestDirectory>$(RepositoryRoot)tests\</TestDirectory>
<GitVersionBaseDirectory>$(RepositoryRoot)</GitVersionBaseDirectory>
- <!--<DisableGitVersionTask>true</DisableGitVersionTask>-->
+ <DisableGitVersionTask>true</DisableGitVersionTask>
</PropertyGroup>
<!--
+1231
View File
File diff suppressed because it is too large Load Diff
+78
View File
@@ -0,0 +1,78 @@
{
lib,
openssl,
writeText,
git,
buildDotnetModule,
dotnetCorePackages,
fetchFromGitHub,
testers,
}:
let
nuget-config = writeText "nuget.config" ''
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>
'';
in
buildDotnetModule (finalAttrs: {
pname = "recyclarr";
version = "7.2.1";
src = fetchFromGitHub {
owner = "recyclarr";
repo = "recyclarr";
rev = "v${finalAttrs.version}";
hash = "sha256-KXFGT1fprRKN+V+3k0hpjjaI/xpw6UDAk+jj9zMek7k=";
};
projectFile = "Recyclarr.sln";
nugetDeps = ./deps.nix;
prePatch = ''
substituteInPlace src/Recyclarr.Cli/Program.cs \
--replace-fail '$"v{GitVersionInformation.SemVer} ({GitVersionInformation.FullBuildMetaData})"' '"${finalAttrs.version}-nixpkgs"'
substituteInPlace src/Recyclarr.Cli/Console/Setup/ProgramInformationDisplayTask.cs \
--replace-fail 'GitVersionInformation.InformationalVersion' '"${finalAttrs.version}-nixpkgs"'
'';
patches = [ ./001-Git-Version.patch ];
dotnetRestoreFlags = [ "--configfile=${nuget-config}" ];
doCheck = false;
dotnet-sdk = dotnetCorePackages.sdk_8_0;
dotnet-runtime = dotnetCorePackages.runtime_8_0;
dotnet-test-sdk = dotnetCorePackages.sdk_8_0;
executables = [ "recyclarr" ];
makeWrapperArgs = [
"--prefix PATH : ${
lib.makeBinPath [
git
openssl
]
}"
];
passthru = {
updateScript = ./update.sh;
tests.version = testers.testVersion { package = finalAttrs.finalPackage; };
};
meta = {
description = "Automatically sync TRaSH guides to your Sonarr and Radarr instances";
homepage = "https://recyclarr.dev/";
changelog = "https://github.com/recyclarr/recyclarr/releases/tag/v${finalAttrs.version}";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [
josephst
aldoborrero
];
mainProgram = "recyclarr";
sourceProvenance = with lib.sourceTypes; [ fromSource ];
};
})
+20
View File
@@ -0,0 +1,20 @@
#!/usr/bin/env nix-shell
#!nix-shell -I nixpkgs=./. -i bash -p curl jq common-updater-scripts gnused nix coreutils
#shellcheck shell=bash
#shellcheck source=/dev/null
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
update-source-version recyclarr "$latestVersion"
. "$(nix-build . -A recyclarr.fetch-deps --no-out-link)"
-91
View File
@@ -1,91 +0,0 @@
{ lib
, stdenv
, fetchurl
, makeWrapper
, autoPatchelfHook
, fixDarwinDylibNames
, darwin
, recyclarr
, git
, icu
, openssl
, 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-LMAY1UIwvB+ne4rpwLKaYO6QGTwdiS3YBndr73zIzvQ=";
arm64-linux_hash = "sha256-by3PSYdN7TPjA0Cx4pfzIbpZ/YVU1agfcuvuZh6mbfU=";
x64-osx_hash = "sha256-/YqdlVktgbBUNdm+mAD053pf6wCMXYt6gQP+iTQdKqw=";
arm64-osx_hash = "sha256-2RRQGNTztK14KDFRqgpagNCWTizHVNY67psaxFfyDZ4=";
}."${arch}-${os}_hash";
libPath = {
osx = "DYLD_LIBRARY_PATH : ${lib.makeLibraryPath [darwin.ICU openssl zlib]}";
linux = "LD_LIBRARY_PATH : ${lib.makeLibraryPath [icu openssl zlib]}";
}."${os}";
in
stdenv.mkDerivation rec {
pname = "recyclarr";
version = "7.0.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;
version = "v${version}";
};
};
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 ];
mainProgram = "recyclarr";
platforms = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
};
}
-31
View File
@@ -1,31 +0,0 @@
#!/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"
}
update-source-version recyclarr "$latestVersion" $(get_hash osx arm64 "$latestVersion") --system="aarch64-darwin" --ignore-same-version
update-source-version recyclarr "$latestVersion" $(get_hash osx x64 "$latestVersion") --system="x86_64-darwin" --ignore-same-version
update-source-version recyclarr "$latestVersion" $(get_hash linux arm64 "$latestVersion") --system="aarch64-linux" --ignore-same-version
update-source-version recyclarr "$latestVersion" $(get_hash linux x64 "$latestVersion") --system="x86_64-linux" --ignore-same-version
-2
View File
@@ -6108,8 +6108,6 @@ with pkgs;
razergenie = libsForQt5.callPackage ../applications/misc/razergenie { };
recyclarr = callPackage ../tools/video/recyclarr { };
tsduck = callPackage ../tools/video/tsduck { };
turso-cli = callPackage ../development/tools/turso-cli {};