Refactor fetchHex out of buildHex.

This will allow to reuse this code to fetch rebar3's dependencies to
ensure it's hermetic build.
This commit is contained in:
Gleb Peregud
2015-12-15 14:01:38 +01:00
parent acaf2c179e
commit 033902d269
3 changed files with 42 additions and 12 deletions
@@ -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;
})