avdump3: fix runtime on .NET 8 (was broken on EOL .NET 6)

The app targets net6.0, but dotnet-runtime in nixpkgs points to .NET 8.
This made the package fail at runtime unless the user also set
NIXPKGS_ALLOW_INSECURE=1 to pull in the EOL dotnet-runtime_6.

Patch the runtimeconfig.json to set rollForward=major so the app runs
on whatever dotnet-runtime version nixpkgs provides.

Other fixes while here:
- Use autoPatchelfHook instead of LD_LIBRARY_PATH + dontPatchELF
- Add libzen (needed by the bundled MediaInfo .so)
- Add symlinks for native libs so DllImport resolves them
- Use makeBinaryWrapper instead of a hand-written shell wrapper
This commit is contained in:
Jamie Magee
2026-02-18 21:01:25 -08:00
parent 6f837c07bf
commit 3b97e45b81
+27 -9
View File
@@ -2,9 +2,12 @@
lib,
stdenv,
fetchzip,
autoPatchelfHook,
makeBinaryWrapper,
jq,
dotnet-runtime,
zlib,
runtimeShell,
libzen,
}:
stdenv.mkDerivation {
@@ -17,21 +20,36 @@ stdenv.mkDerivation {
stripRoot = false;
};
nativeBuildInputs = [
autoPatchelfHook
makeBinaryWrapper
jq
];
buildInputs = [
zlib
libzen
stdenv.cc.cc.lib
];
installPhase = ''
runHook preInstall
mkdir -p $out/share/avdump3 $out/bin
mv * $out/share/avdump3
cat > $out/bin/avdump3 <<EOF
#!${runtimeShell}
export LD_LIBRARY_PATH="${lib.makeLibraryPath [ zlib ]}:\$LD_LIBRARY_PATH"
exec ${dotnet-runtime}/bin/dotnet $out/share/avdump3/AVDump3CL.dll "\$@"
EOF
chmod +x $out/bin/avdump3
# The app targets net6.0, which is EOL. Allow roll-forward to whatever
# major version dotnet-runtime provides.
jq '.runtimeOptions.rollForward = "major"' \
$out/share/avdump3/AVDump3CL.runtimeconfig.json > tmp.json
mv tmp.json $out/share/avdump3/AVDump3CL.runtimeconfig.json
makeBinaryWrapper ${dotnet-runtime}/bin/dotnet $out/bin/avdump3 \
--add-flags $out/share/avdump3/AVDump3CL.dll
runHook postInstall
'';
dontPatchELF = true;
meta = {
mainProgram = "avdump3";
description = "Tool for extracting audio/video metadata from media files and uploading it to AniDB";