diff --git a/pkgs/development/erlang-modules/build-hex.nix b/pkgs/development/erlang-modules/build-hex.nix index a14cd3add55e..bb01c3fb505a 100644 --- a/pkgs/development/erlang-modules/build-hex.nix +++ b/pkgs/development/erlang-modules/build-hex.nix @@ -1,4 +1,4 @@ -{ stdenv, erlang, rebar3, openssl, libyaml, fetchurl, fetchFromGitHub, +{ stdenv, erlang, rebar3, openssl, libyaml, fetchHex, fetchFromGitHub, rebar3-pc }: { name, version, sha256 @@ -16,6 +16,12 @@ stdenv.mkDerivation (attrs // { buildInputs = buildInputs ++ [ erlang rebar3 openssl libyaml ]; + src = fetchHex { + pkg = hexPkg; + inherit version; + inherit sha256; + }; + postPatch = let registrySnapshot = import ./registrySnapshot.nix { inherit fetchFromGitHub; }; in '' @@ -35,12 +41,6 @@ stdenv.mkDerivation (attrs // { ${postPatch} ''; - unpackCmd = '' - tar -xf $curSrc contents.tar.gz - mkdir contents - tar -C contents -xzf contents.tar.gz - ''; - configurePhase = let plugins = pluginDeps ++ (if compilePorts then [rebar3-pc] else []); getDeps = drv: [drv] ++ (map getDeps drv.erlangDeps); @@ -84,11 +84,6 @@ stdenv.mkDerivation (attrs // { runHook postInstall ''; - src = fetchurl { - url = "https://s3.amazonaws.com/s3.hex.pm/tarballs/${hexPkg}-${version}.tar"; - sha256 = sha256; - }; - meta = { inherit (erlang.meta) platforms; } // meta; diff --git a/pkgs/development/tools/build-managers/rebar3/fetch-hex.nix b/pkgs/development/tools/build-managers/rebar3/fetch-hex.nix new file mode 100644 index 000000000000..1b1378c10cbd --- /dev/null +++ b/pkgs/development/tools/build-managers/rebar3/fetch-hex.nix @@ -0,0 +1,34 @@ +{ stdenv, fetchurl }: + +{ pkg, version, sha256 +, meta ? {} +}: + +with stdenv.lib; + +stdenv.mkDerivation ({ + name = "hex-source-${pkg}-${version}"; + + src = fetchurl { + url = "https://s3.amazonaws.com/s3.hex.pm/tarballs/${pkg}-${version}.tar"; + inherit sha256; + }; + + phases = [ "unpackPhase" "installPhase" ]; + + unpackCmd = '' + tar -xf $curSrc contents.tar.gz + mkdir contents + tar -C contents -xzf contents.tar.gz + ''; + + installPhase = '' + runHook preInstall + mkdir "$out" + cp -Hrt "$out" . + success=1 + runHook postInstall + ''; + + inherit meta; +}) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 4f24112cf54c..82a148bedcf4 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -5020,6 +5020,7 @@ let rebar = callPackage ../development/tools/build-managers/rebar { }; rebar3 = callPackage ../development/tools/build-managers/rebar3 { }; + fetchHex = callPackage ../development/tools/build-managers/rebar3/fetch-hex.nix { }; erlangPackages = callPackage ../development/erlang-modules { };