Fetch hex.pm registry snapshot with external github repo.

This allows to avoid fetching registry file from S3 at build time,
making the build hermetic and much faster. Automatic tools will be used
to update said external repo content when Hex packages are
imported/update.
This commit is contained in:
Gleb Peregud 2015-12-11 00:00:33 +01:00
parent 3a9110b15c
commit 5d3680d265
1 changed files with 13 additions and 4 deletions

View File

@ -1,4 +1,4 @@
{ stdenv, erlang, rebar3, openssl, libyaml, fetchurl }: { stdenv, erlang, rebar3, openssl, libyaml, fetchurl, fetchFromGitHub }:
{ name, version, sha256 { name, version, sha256
, hexPkg ? name , hexPkg ? name
@ -14,7 +14,14 @@ stdenv.mkDerivation (attrs // {
buildInputs = buildInputs ++ [ erlang rebar3 openssl libyaml ]; buildInputs = buildInputs ++ [ erlang rebar3 openssl libyaml ];
postPatch = '' postPatch = let
registrySnapshot = fetchFromGitHub {
owner = "gleber";
repo = "hex-pm-registry-snapshots";
rev = "48147b0";
sha256 = "0ibfnhrhbka4n6wkhs99fpy3sjab54ip37jgvx2hcfhfr4pxhbxw";
};
in ''
rm -f rebar rebar3 rm -f rebar rebar3
if [ -e "src/${name}.app.src" ]; then if [ -e "src/${name}.app.src" ]; then
sed -i -e 's/{ *vsn *,[^}]*}/{vsn, "${version}"}/' "src/${name}.app.src" sed -i -e 's/{ *vsn *,[^}]*}/{vsn, "${version}"}/' "src/${name}.app.src"
@ -25,6 +32,9 @@ stdenv.mkDerivation (attrs // {
echo "{plugins, [pc]}." >> rebar.config echo "{plugins, [pc]}." >> rebar.config
'' else ''''} '' else ''''}
mkdir -p _build/default/{lib,plugins}/ ./.cache/rebar3/hex/default/
zcat ${registrySnapshot}/registry.ets.gz > .cache/rebar3/hex/default/registry
${postPatch} ${postPatch}
''; '';
@ -44,7 +54,6 @@ stdenv.mkDerivation (attrs // {
}; };
in '' in ''
runHook preConfigure runHook preConfigure
mkdir -p _build/default/{lib,plugins}/
${concatMapStrings (dep: '' ${concatMapStrings (dep: ''
header "linking erlang dependency ${dep}" header "linking erlang dependency ${dep}"
ln -s "${dep}" "_build/default/lib/${dep.packageName}" ln -s "${dep}" "_build/default/lib/${dep.packageName}"
@ -62,7 +71,7 @@ stdenv.mkDerivation (attrs // {
# this hermetic # this hermetic
buildPhase = '' buildPhase = ''
runHook preBuild runHook preBuild
HOME=. rebar3 do update, compile HOME=. rebar3 compile
${if compilePorts then '' ${if compilePorts then ''
HOME=. rebar3 pc compile HOME=. rebar3 pc compile
'' else ''''} '' else ''''}