Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

recyclarr: refactor - build from source #259609

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions pkgs/tools/video/recyclarr/001-Git-Version.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/src/Directory.Build.props b/src/Directory.Build.props
index 8d10c9f..6eb0f42 100644
--- a/src/Directory.Build.props
+++ b/src/Directory.Build.props
@@ -7,7 +7,7 @@
<DebugType>embedded</DebugType>
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
<GitVersionBaseDirectory>$(MSBuildThisFileDirectory)</GitVersionBaseDirectory>
- <!--<DisableGitVersionTask>true</DisableGitVersionTask>-->
+ <DisableGitVersionTask>true</DisableGitVersionTask>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
93 changes: 37 additions & 56 deletions pkgs/tools/video/recyclarr/default.nix
Original file line number Diff line number Diff line change
@@ -1,74 +1,56 @@
{ lib
, stdenv
, fetchurl
, makeWrapper
, autoPatchelfHook
, fixDarwinDylibNames
, darwin
, recyclarr
, writeText
, git
, icu
, buildDotnetModule
, dotnetCorePackages
, fetchFromGitHub
, recyclarr
, 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-Skf3wY52B6KnWS8YurAL0b5Sdkvp4YYn3IvHrAKyvK8=";
arm64-linux_hash = "sha256-66OCz13eLyAfEC3kYUniqq+QhsHoZNBJieXmmsLG5eM=";
x64-osx_hash = "sha256-6cNpfcjwgfxZRlBnZQrZLMPaXDHEXSbS3Z/qcx1Z3HA=";
arm64-osx_hash = "sha256-OkM+LgqXOHzyzEWH6D3czH86Sncym9FpfTFaacp2aN0=";
}."${arch}-${os}_hash";

libPath = {
osx = "DYLD_LIBRARY_PATH : ${lib.makeLibraryPath [darwin.ICU zlib]}";
linux = "LD_LIBRARY_PATH : ${lib.makeLibraryPath [icu zlib]}";
}."${os}";

nuget-config = writeText "nuget.config" ''
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>
'';
in
stdenv.mkDerivation rec {
buildDotnetModule rec {
pname = "recyclarr";
version = "6.0.2";

src = fetchurl {
url = "https://github.com/recyclarr/recyclarr/releases/download/v${version}/recyclarr-${os}-${arch}.tar.xz";
inherit hash;
src = fetchFromGitHub {
owner = "recyclarr";
repo = pname;
rev = "v${version}";
hash = "sha256-kDptVN2cRGZI6pKE62IKgQqOKpkw4o18Eb+ySQJqG8k=";
};

sourceRoot = ".";
projectFile = "src/Recyclarr.sln";
nugetDeps = ./deps.nix;

nativeBuildInputs = [ makeWrapper ]
++ lib.optional stdenv.isLinux autoPatchelfHook
++ lib.optional stdenv.isDarwin fixDarwinDylibNames;
buildInputs = [ icu zlib ];
prePatch = ''
substituteInPlace src/Recyclarr.Cli/Program.cs \
--replace 'GitVersionInformation.InformationalVersion' '"${version}-nixpkgs"'
'';
patches = [
./001-Git-Version.patch
];

installPhase = ''
runHook preInstall
dotnetRestoreFlags = [ "--configfile=${nuget-config}" ];

install -Dm755 recyclarr -t $out/bin
doCheck = false;

runHook postInstall
'';

postInstall = ''
wrapProgram $out/bin/recyclarr \
--prefix PATH : ${lib.makeBinPath [git]} \
--prefix ${libPath}
'';
dotnet-sdk = dotnetCorePackages.sdk_7_0;
dotnet-runtime = dotnetCorePackages.runtime_7_0;
dotnet-test-sdk = dotnetCorePackages.sdk_7_0;

dontStrip = true; # stripping messes up dotnet single-file deployment
executables = [ "recyclarr" ];
makeWrapperArgs = [
"--prefix PATH : ${lib.makeBinPath [git]}"
];

passthru = {
updateScript = ./update.sh;
Expand All @@ -82,8 +64,7 @@ stdenv.mkDerivation rec {
homepage = "https://recyclarr.dev/";
changelog = "https://github.com/recyclarr/recyclarr/releases/tag/v${version}";
license = licenses.mit;
maintainers = with maintainers; [ josephst ];
mainProgram = "recyclarr";
maintainers = with maintainers; [ josephst aldoborrero ];
platforms = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
};
}