diff --git a/pkgs/build-support/dotnet/fetch-nupkg/default.nix b/pkgs/build-support/dotnet/fetch-nupkg/default.nix new file mode 100644 index 000000000000..66bf503a6518 --- /dev/null +++ b/pkgs/build-support/dotnet/fetch-nupkg/default.nix @@ -0,0 +1,67 @@ +{ + symlinkJoin, + fetchurl, + stdenvNoCC, + lib, + unzip, + patchNupkgs, + nugetPackageHook, +}: +{ + pname, + version, + sha256 ? "", + hash ? "", + url ? "https://www.nuget.org/api/v2/package/${pname}/${version}", + installable ? false, +}: +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 = '' + unzip -nqd source $src + chmod -R +rw source + cd source + ''; + + 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 = '' + dir=$out/share/nuget/packages/${lib.toLower pname}/${lib.toLower version} + mkdir -p $dir + cp -r . $dir + echo {} > "$dir"/.nupkg.metadata + ''; + + preFixup = '' + patch-nupkgs $out/share/nuget/packages + ''; + + createInstallableNugetSource = installable; +} diff --git a/pkgs/build-support/dotnet/make-nuget-deps/default.nix b/pkgs/build-support/dotnet/make-nuget-deps/default.nix index 7266a2913732..efc3d07e9777 100644 --- a/pkgs/build-support/dotnet/make-nuget-deps/default.nix +++ b/pkgs/build-support/dotnet/make-nuget-deps/default.nix @@ -5,6 +5,7 @@ , unzip , patchNupkgs , nugetPackageHook +, fetchNupkg }: lib.makeOverridable( { name @@ -15,57 +16,7 @@ lib.makeOverridable( (symlinkJoin { name = "${name}-nuget-deps"; paths = nugetDeps { - fetchNuGet = - { pname - , version - , sha256 ? "" - , hash ? "" - , url ? "https://www.nuget.org/api/v2/package/${pname}/${version}" }: - 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 = '' - unzip -nqd source $src - chmod -R +rw source - cd source - ''; - - 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 = '' - dir=$out/share/nuget/packages/${lib.toLower pname}/${lib.toLower version} - mkdir -p $dir - cp -r . $dir - echo {} > "$dir"/.nupkg.metadata - ''; - - preFixup = '' - patch-nupkgs $out/share/nuget/packages - ''; - - createInstallableNugetSource = installable; - }; + fetchNuGet = args: fetchNupkg (args // { inherit installable; }); }; }) // { inherit sourceFile; diff --git a/pkgs/development/compilers/dotnet/default.nix b/pkgs/development/compilers/dotnet/default.nix index 0604e5706b02..fec4583bf558 100644 --- a/pkgs/development/compilers/dotnet/default.nix +++ b/pkgs/development/compilers/dotnet/default.nix @@ -53,6 +53,7 @@ makeScopeWithSplicing' { mkNugetSource = callPackage ../../../build-support/dotnet/make-nuget-source { }; mkNugetDeps = callPackage ../../../build-support/dotnet/make-nuget-deps { }; + fetchNupkg = callPackage ../../../build-support/dotnet/fetch-nupkg { }; dotnet_8 = recurseIntoAttrs (callPackage ./8 { bootstrapSdk = dotnet_8_0.sdk_8_0_1xx; }); dotnet_9 = recurseIntoAttrs (callPackage ./9 {});