diff --git a/pkgs/development/erlang-modules/build-hex.nix b/pkgs/development/erlang-modules/build-hex.nix index bb01c3fb505a..041a7db48a9c 100644 --- a/pkgs/development/erlang-modules/build-hex.nix +++ b/pkgs/development/erlang-modules/build-hex.nix @@ -22,21 +22,17 @@ stdenv.mkDerivation (attrs // { inherit sha256; }; - postPatch = let - registrySnapshot = import ./registrySnapshot.nix { inherit fetchFromGitHub; }; - in '' + postPatch = '' rm -f rebar rebar3 if [ -e "src/${name}.app.src" ]; then sed -i -e 's/{ *vsn *,[^}]*}/{vsn, "${version}"}/' "src/${name}.app.src" fi - # TODO: figure out how to provide 'pc' plugin hermetically ${if compilePorts then '' echo "{plugins, [pc]}." >> rebar.config '' else ''''} - mkdir -p _build/default/{lib,plugins}/ ./.cache/rebar3/hex/default/ - zcat ${registrySnapshot}/registry.ets.gz > .cache/rebar3/hex/default/registry + ${rebar3.setupRegistry} ${postPatch} ''; @@ -61,8 +57,6 @@ stdenv.mkDerivation (attrs // { runHook postConfigure ''; - # TODO: figure out how to provide rebar3 a static registry snapshot to make - # this hermetic buildPhase = '' runHook preBuild HOME=. rebar3 compile diff --git a/pkgs/development/tools/build-managers/rebar3/default.nix b/pkgs/development/tools/build-managers/rebar3/default.nix index 2e75a12bbfc6..f905622413ad 100644 --- a/pkgs/development/tools/build-managers/rebar3/default.nix +++ b/pkgs/development/tools/build-managers/rebar3/default.nix @@ -1,8 +1,13 @@ -{ stdenv, fetchurl, erlang }: +{ stdenv, fetchurl, erlang, tree, fetchFromGitHub }: let version = "3.0.0-beta.4"; + registrySnapshot = import ./registrySnapshot.nix { inherit fetchFromGitHub; }; + setupRegistry = '' + mkdir -p _build/default/{lib,plugins,packages}/ ./.cache/rebar3/hex/default/ + zcat ${registrySnapshot}/registry.ets.gz > .cache/rebar3/hex/default/registry + ''; in stdenv.mkDerivation { name = "rebar3-${version}"; @@ -13,8 +18,11 @@ stdenv.mkDerivation { }; buildInputs = [ erlang ]; + inherit setupRegistry; + buildPhase = '' + ${setupRegistry} HOME=. escript bootstrap ''; installPhase = '' diff --git a/pkgs/development/erlang-modules/registrySnapshot.nix b/pkgs/development/tools/build-managers/rebar3/registrySnapshot.nix similarity index 100% rename from pkgs/development/erlang-modules/registrySnapshot.nix rename to pkgs/development/tools/build-managers/rebar3/registrySnapshot.nix