dotnetCorePackages.fetchNupkg: add override mechanism

This commit is contained in:
David McFarland 2024-09-03 23:33:28 -03:00
parent 32ccfdc278
commit 1f6cd35f5e
2 changed files with 70 additions and 56 deletions

View File

@ -6,6 +6,8 @@
unzip,
patchNupkgs,
nugetPackageHook,
callPackage,
overrides ? callPackage ./overrides.nix { },
}:
{
pname,
@ -15,61 +17,64 @@
url ? "https://www.nuget.org/api/v2/package/${pname}/${version}",
installable ? false,
}:
stdenvNoCC.mkDerivation rec {
inherit pname version;
let
package = stdenvNoCC.mkDerivation rec {
inherit pname version;
src = fetchurl {
name = "${pname}.${version}.nupkg";
# There is no need to verify whether both sha256 and hash are
# valid here, because nuget-to-nix does not generate a deps.nix
# containing both.
inherit
url
sha256
hash
version
;
src = fetchurl {
name = "${pname}.${version}.nupkg";
# There is no need to verify whether both sha256 and hash are
# valid here, because nuget-to-nix does not generate a deps.nix
# containing both.
inherit
url
sha256
hash
version
;
};
nativeBuildInputs = [
unzip
patchNupkgs
nugetPackageHook
];
unpackPhase = ''
runHook preUnpack
unzip -nqd source $src
chmod -R +rw source
cd source
runHook postUnpack
'';
prePatch = ''
shopt -s nullglob
local dir
for dir in tools runtimes/*/native; do
[[ ! -d "$dir" ]] || chmod -R +x "$dir"
done
rm -rf .signature.p7s
'';
installPhase = ''
runHook preInstall
dir=$out/share/nuget/packages/${lib.toLower pname}/${lib.toLower version}
mkdir -p $dir
cp -r . $dir
echo {} > "$dir"/.nupkg.metadata
runHook postInstall
'';
preFixup = ''
patch-nupkgs $out/share/nuget/packages
'';
createInstallableNugetSource = installable;
};
nativeBuildInputs = [
unzip
patchNupkgs
nugetPackageHook
];
unpackPhase = ''
runHook preUnpack
unzip -nqd source $src
chmod -R +rw source
cd source
runHook postUnpack
'';
prePatch = ''
shopt -s nullglob
local dir
for dir in tools runtimes/*/native; do
[[ ! -d "$dir" ]] || chmod -R +x "$dir"
done
rm -rf .signature.p7s
'';
installPhase = ''
runHook preInstall
dir=$out/share/nuget/packages/${lib.toLower pname}/${lib.toLower version}
mkdir -p $dir
cp -r . $dir
echo {} > "$dir"/.nupkg.metadata
runHook postInstall
'';
preFixup = ''
patch-nupkgs $out/share/nuget/packages
'';
createInstallableNugetSource = installable;
}
in
overrides.${pname} or lib.id package

View File

@ -0,0 +1,9 @@
{ autoPatchelfHook }:
{
# e.g.
# "Package.Id" =
# package:
# package.overrideAttrs (old: {
# buildInputs = old.buildInputs or [ ] ++ [ hello ];
# });
}