Commit 7ea78aaf authored by David McFarland's avatar David McFarland
Browse files

dotnetCorePackages.fetchNupkg: split from mkNugetDeps

parent d4776214
Loading
Loading
Loading
Loading
+67 −0
Original line number Diff line number Diff line
{
  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;
}
+2 −51
Original line number Diff line number Diff line
@@ -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;
+1 −0
Original line number Diff line number Diff line
@@ -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 {});