1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-22 21:50:55 +00:00

Merge pull request #54115 from k32/master

rebar3: 3.6.1 -> 3.9.0
This commit is contained in:
Silvan Mosberger 2019-02-09 17:29:59 +01:00 committed by GitHub
commit 18d059a4ac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 195 additions and 227 deletions

View file

@ -23,12 +23,8 @@ let
hexRegistrySnapshot = callPackage ./hex-registry-snapshot.nix { };
rebar = callPackage ../tools/build-managers/rebar { };
rebar3-open = callPackage ../tools/build-managers/rebar3 {
hermeticRebar3 = false;
};
rebar3 = callPackage ../tools/build-managers/rebar3 {
hermeticRebar3 = true;
};
rebar3-open = callPackage ../tools/build-managers/rebar3 { };
rebar3 = callPackage ../tools/build-managers/rebar3 { };
# rebar3 port compiler plugin is required by buildRebar3
pc_1_6_0 = callPackage ./pc {};
@ -36,6 +32,9 @@ let
fetchHex = callPackage ./fetch-hex.nix { };
fetchRebar3Deps = callPackage ./fetch-rebar-deps.nix { };
rebar3Relx = callPackage ./rebar3-release.nix { };
buildRebar3 = callPackage ./build-rebar3.nix {};
buildHex = callPackage ./build-hex.nix {};
buildErlangMk = callPackage ./build-erlang-mk.nix {};
@ -75,25 +74,6 @@ let
lfe = lfe_1_2;
lfe_1_2 = lib.callLFE ../interpreters/lfe/1.2.nix { inherit erlang buildRebar3 buildHex; };
# We list all base hex packages for beam tooling explicitly to ensure
# tha the tooling does not break during hex-packages.nix updates.
erlware_commons_1_0_0 = buildHex {
name = "erlware_commons";
version = "1.0.0";
sha256 = "0wkphbrjk19lxdwndy92v058qwcaz13bcgdzp33h21aa7vminzx7";
beamDeps = [ cf_0_2_2 ];
};
cf_0_2_2 = buildHex {
name = "cf";
version = "0.2.2";
sha256 = "08cvy7skn5d2k4manlx5k3anqgjdvajjhc5jwxbaszxw34q3na28";
};
getopt_0_8_2 = buildHex {
name = "getopt";
version = "0.8.2";
sha256 = "1xw30h59zbw957cyjd8n50hf9y09jnv9dyry6x3avfwzcyrnsvkk";
};
# Non hex packages. Examples how to build Rebar/Mix packages with and
# without helper functions buildRebar3 and buildMix.
hex = callPackage ./hex {};

View file

@ -0,0 +1,32 @@
{ stdenv, rebar3, curl }:
{ name, version, sha256, src
, meta ? {}
}:
with stdenv.lib;
stdenv.mkDerivation ({
name = "rebar-deps-${name}-${version}";
phases = [ "downloadPhase" "installPhase" ];
downloadPhase = ''
cp ${src} .
HOME='.' DEBUG=1 ${rebar3}/bin/rebar3 get-deps
'';
installPhase = ''
mkdir -p "$out/_checkouts"
for i in ./_build/default/lib/* ; do
echo "$i"
cp -R "$i" "$out/_checkouts"
done
'';
outputHashAlgo = "sha256";
outputHashMode = "recursive";
outputHash = sha256;
impureEnvVars = stdenv.lib.fetchers.proxyImpureEnvVars;
})

View file

@ -0,0 +1,85 @@
{ stdenv, writeText, erlang, rebar3, openssl, libyaml,
pc, lib }:
{ name, version
, src
, checkouts ? null
, releaseType
, buildInputs ? []
, setupHook ? null
, profile ? "default"
, installPhase ? null
, buildPhase ? null
, configurePhase ? null
, meta ? {}
, enableDebugInfo ? false
, ... }@attrs:
with stdenv.lib;
let
debugInfoFlag = lib.optionalString (enableDebugInfo || erlang.debugInfo) "debug-info";
shell = drv: stdenv.mkDerivation {
name = "interactive-shell-${drv.name}";
buildInputs = [ drv ];
};
customPhases = filterAttrs
(_: v: v != null)
{ inherit setupHook configurePhase buildPhase installPhase; };
pkg = self: stdenv.mkDerivation (attrs // {
name = "${name}-${version}";
inherit version;
buildInputs = buildInputs ++ [ erlang rebar3 openssl ];
propagatedBuildInputs = [checkouts];
dontStrip = true;
inherit src;
setupHook = writeText "setupHook.sh" ''
addToSearchPath ERL_LIBS "$1/lib/erlang/lib/"
'';
configurePhase = ''
runHook preConfigure
${if checkouts != null then
''cp --no-preserve=all -R ${checkouts}/_checkouts .''
else
''''}
runHook postConfigure
'';
buildPhase = ''
runHook preBuild
HOME=. DEBUG=1 rebar3 as ${profile} ${if releaseType == "escript"
then '' escriptize''
else '' release''}
runHook postBuild
'';
installPhase = ''
runHook preInstall
dir=${if releaseType == "escript"
then ''bin''
else ''rel''}
mkdir -p "$out/$dir"
cp -R --preserve=mode "_build/${profile}/$dir" "$out"
runHook postInstall
'';
meta = {
inherit (erlang.meta) platforms;
} // meta;
passthru = {
packageName = name;
env = shell self;
};
} // customPhases);
in
fix pkg

View file

@ -1,46 +1,46 @@
{ stdenv, fetchurl,
fetchHex, erlang, hermeticRebar3 ? true,
fetchHex, erlang,
tree, hexRegistrySnapshot }:
let
version = "3.6.1";
version = "3.9.0";
bootstrapper = ./rebar3-nix-bootstrap;
erlware_commons = fetchHex {
pkg = "erlware_commons";
version = "1.2.0";
sha256 = "149kkn9gc9cjgvlmakygq475r63q2rry31s29ax0s425dh37sfl7";
version = "1.3.1";
sha256 = "7aada93f368d0a0430122e39931b7fb4ac9e94dbf043cdc980ad4330fd9cd166";
};
ssl_verify_fun = fetchHex {
pkg = "ssl_verify_fun";
version = "1.1.3";
sha256 = "1zljxashfhqmiscmf298vhr880ppwbgi2rl3nbnyvsfn0mjhw4if";
sha256 = "2e120e6505d6e9ededb2836611dfe2f7028432dc280957998e154307b5ea92fe";
};
certifi = fetchHex {
pkg = "certifi";
version = "2.0.0";
sha256 = "075v7cvny52jbhnskchd3fp68fxgp7qfvdls0haamcycxrn0dipx";
version = "2.3.1";
sha256 = "e12d667d042c11d130594bae2b0097e63836fe8b1e6d6b2cc48f8bb7a2cf7d68";
};
providers = fetchHex {
pkg = "providers";
version = "1.7.0";
sha256 = "19p4rbsdx9lm2ihgvlhxyld1q76kxpd7qwyqxxsgmhl5r8ln3rlb";
sha256 = "8be66129ca85c2fa74efd8737cdaedd31c1c1af51dd2fd601495a6def4cae4a6";
};
getopt = fetchHex {
pkg = "getopt";
version = "1.0.1";
sha256 = "174mb46c2qd1f4a7507fng4vvscjh1ds7rykfab5rdnfp61spqak";
sha256 = "53e1ab83b9ceb65c9672d3e7a35b8092e9bdc9b3ee80721471a161c10c59959c";
};
bbmustache = fetchHex {
pkg = "bbmustache";
version = "1.5.0";
sha256 = "0xg3r4lxhqifrv32nm55b4zmkflacc1s964g15p6y6jfx6v4y1zd";
version = "1.6.0";
sha256 = "53e02d296512a57be03a98c91541b34d2ca64930268030b2d12364a0332015df";
};
relx = fetchHex {
pkg = "relx";
version = "3.26.0";
sha256 = "1f810rb01kdidpa985s321ycg3y4hvqpzbk263n6i1bfnqykkvv9";
version = "3.28.0";
sha256 = "8afb871c0a2a27f0063d973903fc64d2207bc705ecc3607462920683d24ac7b5";
};
cf = fetchHex {
pkg = "cf";
@ -49,59 +49,71 @@ let
};
cth_readable = fetchHex {
pkg = "cth_readable";
version = "1.4.2";
sha256 = "1pjid4f60pp81ds01rqa6ybksrnzqriw3aibilld1asn9iabxkav";
version = "1.4.3";
sha256 = "0wr0hba6ka74s3628jrrd7ynjdh7syxigkh7ildg8fgi20ab88fd";
};
eunit_formatters = fetchHex {
pkg = "eunit_formatters";
version = "0.5.0";
sha256 = "1jb3hzb216r29x2h4pcjwfmx1k81431rgh5v0mp4x5146hhvmj6n";
};
rebar3_hex = fetchHex {
pkg = "rebar3_hex";
version = "4.0.0";
sha256 = "0k0ykx1lz62r03dpbi2zxsvrxgnr5hj67yky0hjrls09ynk4682v";
hex_core = fetchHex {
pkg = "hex_core";
version = "0.4.0";
sha256 = "8ace8c6cfa10df4cb8be876f42f7446890e124203c094cc7b4e7616fb8de5d7f";
};
parse_trans = fetchHex {
pkg = "parse_trans";
version = "3.3.0";
sha256 = "17ef63abde837ad30680ea7f857dd9e7ced9476cdd7b0394432af4bfc241b960";
};
in
stdenv.mkDerivation {
name = "rebar3-${version}";
inherit version;
inherit version erlang;
src = fetchurl {
url = "https://github.com/rebar/rebar3/archive/${version}.tar.gz";
sha256 = "0cqhqymzh10pfyxqiy4hcg3d2myz3chx0y4m2ixmq8zk81acics0";
sha256 = "14prx5bkyy9sisnp5rj2058xpylq80xygsj1hq8b7m0awvj3r9wy";
};
inherit bootstrapper;
patches = if hermeticRebar3 == true
then [ ./hermetic-rebar3.patch ]
else [];
buildInputs = [ erlang tree ];
buildInputs = [ erlang tree ];
# TODO: Remove registry snapshot
propagatedBuildInputs = [ hexRegistrySnapshot ];
postPatch = ''
${erlang}/bin/escript ${bootstrapper} registry-only
mkdir -p _checkouts
mkdir -p _build/default/lib/
mkdir -p _build/default/plugins
cp --no-preserve=mode -R ${erlware_commons} _build/default/lib/erlware_commons
cp --no-preserve=mode -R ${providers} _build/default/lib/providers
cp --no-preserve=mode -R ${getopt} _build/default/lib/getopt
cp --no-preserve=mode -R ${bbmustache} _build/default/lib/bbmustache
cp --no-preserve=mode -R ${certifi} _build/default/lib/certifi
cp --no-preserve=mode -R ${cf} _build/default/lib/cf
cp --no-preserve=mode -R ${cth_readable} _build/default/lib/cth_readable
cp --no-preserve=mode -R ${eunit_formatters} _build/default/lib/eunit_formatters
cp --no-preserve=mode -R ${relx} _build/default/lib/relx
cp --no-preserve=mode -R ${ssl_verify_fun} _build/default/lib/ssl_verify_fun
cp --no-preserve=mode -R ${rebar3_hex} _build/default/plugins/rebar3_hex
cp --no-preserve=mode -R ${erlware_commons} _checkouts/erlware_commons
cp --no-preserve=mode -R ${providers} _checkouts/providers
cp --no-preserve=mode -R ${getopt} _checkouts/getopt
cp --no-preserve=mode -R ${bbmustache} _checkouts/bbmustache
cp --no-preserve=mode -R ${certifi} _checkouts/certifi
cp --no-preserve=mode -R ${cf} _checkouts/cf
cp --no-preserve=mode -R ${cth_readable} _checkouts/cth_readable
cp --no-preserve=mode -R ${eunit_formatters} _checkouts/eunit_formatters
cp --no-preserve=mode -R ${relx} _checkouts/relx
cp --no-preserve=mode -R ${ssl_verify_fun} _checkouts/ssl_verify_fun
cp --no-preserve=mode -R ${hex_core} _checkouts/hex_core
cp --no-preserve=mode -R ${parse_trans} _checkouts/parse_trans
# Bootstrap script expects the dependencies in _build/default/lib
# TODO: Make it accept checkouts?
for i in _checkouts/* ; do
ln -s $(pwd)/$i $(pwd)/_build/default/lib/
done
'';
buildPhase = ''
HOME=. escript bootstrap
'';
installPhase = ''
mkdir -p $out/bin
cp rebar3 $out/bin/rebar3
@ -109,7 +121,7 @@ stdenv.mkDerivation {
meta = {
homepage = https://github.com/rebar/rebar3;
description = "rebar 3.0 is an Erlang build tool that makes it easy to compile and test Erlang applications, port drivers and releases";
description = "rebar 3 is an Erlang build tool that makes it easy to compile and test Erlang applications, port drivers and releases";
longDescription = ''
rebar is a self-contained Erlang script, so it's easy to distribute or

View file

@ -1,103 +0,0 @@
diff --git a/bootstrap b/bootstrap
index 5dedd713..864056c4 100755
--- a/bootstrap
+++ b/bootstrap
@@ -101,7 +101,7 @@ extract(Binary) ->
request(Url) ->
HttpOptions = [{relaxed, true} | get_proxy_auth()],
- case httpc:request(get, {Url, []},
+ case rebar_hermeticity:request(get, {Url, []},
HttpOptions,
[{body_format, binary}],
rebar) of
diff --git a/src/rebar_hermeticity.erl b/src/rebar_hermeticity.erl
index e69de29b..8f6cc7d0 100644
--- a/src/rebar_hermeticity.erl
+++ b/src/rebar_hermeticity.erl
@@ -0,0 +1,42 @@
+%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
+%% ex: ts=4 sw=4 et
+%% -------------------------------------------------------------------
+%%
+%% rebar: Erlang Build Tools
+%%
+%% Copyright (c) 2016 Eric Merritt (eric@merritt.tech)
+%%
+%% Permission is hereby granted, free of charge, to any person obtaining a copy
+%% of this software and associated documentation files (the "Software"), to deal
+%% in the Software without restriction, including without limitation the rights
+%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+%% copies of the Software, and to permit persons to whom the Software is
+%% furnished to do so, subject to the following conditions:
+%%
+%% The above copyright notice and this permission notice shall be included in
+%% all copies or substantial portions of the Software.
+%%
+%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+%% THE SOFTWARE.
+%% -------------------------------------------------------------------
+-module(rebar_hermeticity).
+
+-export([request/5]).
+
+-include("rebar.hrl").
+
+%% ====================================================================
+%% Public API
+%% ====================================================================
+
+request(Method, {Url, _Headers}, _HTTPOptions, _Options, _Profile) ->
+ ?ERROR("A request is being made that violates Nix hermicity "
+ "This request has been stopped. Details of the request "
+ "are as follows:", []),
+ ?ERROR("Request: ~p ~s", [Method, Url]),
+ erlang:halt(1).
diff --git a/src/rebar_pkg_resource.erl b/src/rebar_pkg_resource.erl
index 2cf167ee..6080aaca 100644
--- a/src/rebar_pkg_resource.erl
+++ b/src/rebar_pkg_resource.erl
@@ -127,7 +127,7 @@ make_vsn(_) ->
request(Url, ETag) ->
HttpOptions = [{ssl, ssl_opts(Url)},
{relaxed, true} | rebar_utils:get_proxy_auth()],
- case httpc:request(get, {Url, [{"if-none-match", "\"" ++ ETag ++ "\""}
+ case rebar_hermeticity:request(get, {Url, [{"if-none-match", "\"" ++ ETag ++ "\""}
|| ETag =/= false] ++
[{"User-Agent", rebar_utils:user_agent()}]},
HttpOptions, [{body_format, binary}], rebar) of
diff --git a/src/rebar_prv_update.erl b/src/rebar_prv_update.erl
index 17446311..4d44d794 100644
--- a/src/rebar_prv_update.erl
+++ b/src/rebar_prv_update.erl
@@ -38,6 +38,8 @@ init(State) ->
{ok, State1}.
-spec do(rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}.
+do(State) -> {ok, State}.
+-ifdef(non_hermetic).
do(State) ->
try
case rebar_packages:registry_dir(State) of
@@ -53,7 +55,7 @@ do(State) ->
{ok, Url} ->
HttpOptions = [{relaxed, true} | rebar_utils:get_proxy_auth()],
?DEBUG("Fetching registry from ~p", [Url]),
- case httpc:request(get, {Url, [{"User-Agent", rebar_utils:user_agent()}]},
+ case rebar_hermeticity:request(get, {Url, [{"User-Agent", rebar_utils:user_agent()}]},
HttpOptions, [{stream, TmpFile}, {sync, true}],
rebar) of
{ok, saved_to_file} ->
@@ -77,6 +79,7 @@ do(State) ->
?DEBUG("Error creating package index: ~p ~p", [C, S]),
throw(?PRV_ERROR(package_index_write))
end.
+-endif.
-spec format_error(any()) -> iolist().
format_error({package_parse_cdn, Uri}) ->

View file

@ -1,29 +1,21 @@
{ fetchFromGitHub, buildRebar3,
{ fetchFromGitHub, fetchRebar3Deps, rebar3Relx }:
# Erlang dependencies:
ibrowse_4_2_2,
getopt_0_8_2,
erlware_commons_1_0_0,
jsx_2_8_0 }:
buildRebar3 rec {
rebar3Relx rec {
name = "hex2nix";
version = "0.0.6-a31eadd7";
releaseType = "escript";
checkouts = fetchRebar3Deps {
inherit name version;
src = "${src}/rebar.config";
sha256 = "1b59vk6ynakdiwqd1s6axaj9bvkaaq7ll28b48nv613z892h7nm5";
};
src = fetchFromGitHub {
owner = "erlang-nix";
repo = "hex2nix";
rev = "a31eadd7af2cbdac1b87991b378e98ea4fb40ae0";
sha256 = "1hnkrksyrbpq2gq25rfsrnm86n0g3biab88gswm3zj88ddrz6dyk";
};
beamDeps = [ ibrowse_4_2_2 jsx_2_8_0 erlware_commons_1_0_0 getopt_0_8_2 ];
enableDebugInfo = true;
installPhase = ''
runHook preInstall
make PREFIX=$out install
runHook postInstall
'';
}
}

View file

@ -1,49 +1,19 @@
{ stdenv, buildHex
{ stdenv, fetchHex, fetchRebar3Deps, rebar3Relx }:
, getopt_0_8_2, erlware_commons_1_0_0, cf_0_2_2 }:
let
providers_1_6_0 = buildHex {
name = "providers";
version = "1.6.0";
sha256 = "0byfa1h57n46jilz4q132j0vk3iqc0v1vip89li38gb1k997cs0g";
beamDeps = [ getopt_0_8_2 ];
};
bbmustache_1_0_4 = buildHex {
name = "bbmustache";
version = "1.0.4";
sha256 = "04lvwm7f78x8bys0js33higswjkyimbygp4n72cxz1kfnryx9c03";
};
in
buildHex rec {
rebar3Relx rec {
name = "relx-exe";
version = "3.23.1";
hexPkg = "relx";
sha256 = "13j7wds2d7b8v3r9pwy3zhwhzywgwhn6l9gm3slqzyrs1jld0a9d";
releaseType = "escript";
beamDeps = [
providers_1_6_0
getopt_0_8_2
erlware_commons_1_0_0
cf_0_2_2
bbmustache_1_0_4
];
postBuild = ''
HOME=. rebar3 escriptize
'';
postInstall = ''
mkdir -p "$out/bin"
cp -r "_build/default/bin/relx" "$out/bin/relx"
'';
meta = {
description = "Executable command for Relx";
license = stdenv.lib.licenses.asl20;
homepage = "https://github.com/erlware/relx";
maintainers = with stdenv.lib.maintainers; [ ericbmerritt ];
src = fetchHex {
pkg = "relx";
sha256 = "13j7wds2d7b8v3r9pwy3zhwhzywgwhn6l9gm3slqzyrs1jld0a9d";
version = "3.23.1";
};
checkouts = fetchRebar3Deps {
inherit name version;
src = "${src}/rebar.lock";
sha256 = "046b1lb9rymndlvzmin3ppa3vkssjqspyfp98869k11s5avg76hd";
};
}