-
-
Notifications
You must be signed in to change notification settings - Fork 14.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dotnet: add override mechanism for nuget packages (#339953)
- Loading branch information
Showing
33 changed files
with
268 additions
and
227 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
{ | ||
symlinkJoin, | ||
fetchurl, | ||
stdenvNoCC, | ||
lib, | ||
unzip, | ||
patchNupkgs, | ||
nugetPackageHook, | ||
callPackage, | ||
overrides ? callPackage ./overrides.nix { }, | ||
}: | ||
{ | ||
pname, | ||
version, | ||
sha256 ? "", | ||
hash ? "", | ||
url ? "https://www.nuget.org/api/v2/package/${pname}/${version}", | ||
installable ? false, | ||
}: | ||
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 | ||
; | ||
}; | ||
|
||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
{ | ||
autoPatchelfHook, | ||
dotnetCorePackages, | ||
fontconfig, | ||
lib, | ||
libICE, | ||
libSM, | ||
libX11, | ||
stdenv, | ||
writeText, | ||
}: | ||
{ | ||
# e.g. | ||
# "Package.Id" = | ||
# package: | ||
# package.overrideAttrs (old: { | ||
# buildInputs = old.buildInputs or [ ] ++ [ hello ]; | ||
# }); | ||
|
||
"Avalonia.X11" = | ||
package: | ||
package.overrideAttrs ( | ||
old: | ||
lib.optionalAttrs (!stdenv.isDarwin) { | ||
setupHook = writeText "setupHook.sh" '' | ||
prependToVar dotnetRuntimeDeps \ | ||
"${lib.getLib libICE}" \ | ||
"${lib.getLib libSM}" \ | ||
"${lib.getLib libX11}" | ||
''; | ||
} | ||
); | ||
|
||
"SkiaSharp.NativeAssets.Linux" = | ||
package: | ||
package.overrideAttrs ( | ||
old: | ||
lib.optionalAttrs stdenv.isLinux { | ||
nativeBuildInputs = old.nativeBuildInputs or [ ] ++ [ autoPatchelfHook ]; | ||
|
||
buildInputs = old.buildInputs or [ ] ++ [ fontconfig ]; | ||
|
||
preInstall = | ||
old.preInstall or "" | ||
+ '' | ||
cd runtimes | ||
for platform in *; do | ||
[[ $platform == "${dotnetCorePackages.systemToDotnetRid stdenv.hostPlatform.system}" ]] || | ||
rm -r "$platform" | ||
done | ||
cd - >/dev/null | ||
''; | ||
} | ||
); | ||
} |
Oops, something went wrong.