Merge pull request #11651 from gleber/add-erlang-modules
Add erlang modules
This commit is contained in:
129
pkgs/development/tools/build-managers/rebar3/default.nix
Normal file
129
pkgs/development/tools/build-managers/rebar3/default.nix
Normal file
@@ -0,0 +1,129 @@
|
||||
{ stdenv, fetchurl, fetchHex, 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
|
||||
'';
|
||||
# TODO: all these below probably should go into nixpkgs.erlangModules.sources.*
|
||||
# {erlware_commons, "0.16.0"},
|
||||
erlware_commons = fetchHex {
|
||||
pkg = "erlware_commons";
|
||||
version = "0.16.0";
|
||||
sha256 = "0kh24d0001390wfx28d0xa874vrsfvjgj41g315vg4hac632krxx";
|
||||
};
|
||||
# {ssl_verify_hostname, "1.0.5"},
|
||||
ssl_verify_hostname = fetchHex {
|
||||
pkg = "ssl_verify_hostname";
|
||||
version = "1.0.5";
|
||||
sha256 = "1gzavzqzljywx4l59gvhkjbr1dip4kxzjjz1s4wsn42f2kk13jzj";
|
||||
};
|
||||
# {certifi, "0.1.1"},
|
||||
certifi = fetchHex {
|
||||
pkg = "certifi";
|
||||
version = "0.1.1";
|
||||
sha256 = "0afylwqg74gprbg116asz0my2nipmki0512c8mdiq6xdiyjdvlg6";
|
||||
};
|
||||
# {providers, "1.5.0"},
|
||||
providers = fetchHex {
|
||||
pkg = "providers";
|
||||
version = "1.5.0";
|
||||
sha256 = "1hc8sp2l1mmx9dfpmh1f8j9hayfg7541rmx05wb9cmvxvih7zyvf";
|
||||
};
|
||||
# {getopt, "0.8.2"},
|
||||
getopt = fetchHex {
|
||||
pkg = "getopt";
|
||||
version = "0.8.2";
|
||||
sha256 = "1xw30h59zbw957cyjd8n50hf9y09jnv9dyry6x3avfwzcyrnsvkk";
|
||||
};
|
||||
# {bbmustache, "1.0.4"},
|
||||
bbmustache = fetchHex {
|
||||
pkg = "bbmustache";
|
||||
version = "1.0.4";
|
||||
sha256 = "04lvwm7f78x8bys0js33higswjkyimbygp4n72cxz1kfnryx9c03";
|
||||
};
|
||||
# {relx, "3.8.0"},
|
||||
relx = fetchHex {
|
||||
pkg = "relx";
|
||||
version = "3.8.0";
|
||||
sha256 = "0y89iirjz3kc1rzkdvc6p3ssmwcm2hqgkklhgm4pkbc14fcz57hq";
|
||||
};
|
||||
# {cf, "0.2.1"},
|
||||
cf = fetchHex {
|
||||
pkg = "cf";
|
||||
version = "0.2.1";
|
||||
sha256 = "19d0yvg8wwa57cqhn3vqfvw978nafw8j2rvb92s3ryidxjkrmvms";
|
||||
};
|
||||
# {cth_readable, "1.1.0"},
|
||||
cth_readable = fetchHex {
|
||||
pkg = "cth_readable";
|
||||
version = "1.0.1";
|
||||
sha256 = "1cnc4fbypckqllfi5h73rdb24dz576k3177gzvp1kbymwkp1xcz1";
|
||||
};
|
||||
# {eunit_formatters, "0.2.0"}
|
||||
eunit_formatters = fetchHex {
|
||||
pkg = "eunit_formatters";
|
||||
version = "0.2.0";
|
||||
sha256 = "03kiszlbgzscfd2ns7na6bzbfzmcqdb5cx3p6qy3657jk2fai332";
|
||||
};
|
||||
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
name = "rebar3-${version}";
|
||||
|
||||
src = fetchurl {
|
||||
url = "https://github.com/rebar/rebar3/archive/${version}.tar.gz";
|
||||
sha256 = "0px66scjdia9aaa5z36qzxb848r56m0k98g0bxw065a2narsh4xy";
|
||||
};
|
||||
|
||||
patches = [ ./hermetic-bootstrap.patch ];
|
||||
|
||||
buildInputs = [ erlang
|
||||
tree
|
||||
];
|
||||
inherit setupRegistry;
|
||||
|
||||
postPatch = ''
|
||||
echo postPatch
|
||||
${setupRegistry}
|
||||
mkdir -p _build/default/lib/
|
||||
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_hostname} _build/default/lib/ssl_verify_hostname
|
||||
'';
|
||||
|
||||
buildPhase = ''
|
||||
HOME=. escript bootstrap
|
||||
'';
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
cp rebar3 $out/bin/rebar3
|
||||
'';
|
||||
|
||||
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.";
|
||||
|
||||
longDescription = ''
|
||||
rebar is a self-contained Erlang script, so it's easy to distribute or
|
||||
even embed directly in a project. Where possible, rebar uses standard
|
||||
Erlang/OTP conventions for project structures, thus minimizing the amount
|
||||
of build configuration work. rebar also provides dependency management,
|
||||
enabling application writers to easily re-use common libraries from a
|
||||
variety of locations (hex.pm, git, hg, and so on).
|
||||
'';
|
||||
|
||||
platforms = stdenv.lib.platforms.unix;
|
||||
maintainers = [ stdenv.lib.maintainers.gleber ];
|
||||
};
|
||||
}
|
||||
34
pkgs/development/tools/build-managers/rebar3/fetch-hex.nix
Normal file
34
pkgs/development/tools/build-managers/rebar3/fetch-hex.nix
Normal file
@@ -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;
|
||||
})
|
||||
@@ -0,0 +1,78 @@
|
||||
diff --git a/bootstrap b/bootstrap
|
||||
index 25bd658..b2a986b 100755
|
||||
--- a/bootstrap
|
||||
+++ b/bootstrap
|
||||
@@ -8,9 +8,6 @@ main(_Args) ->
|
||||
application:start(asn1),
|
||||
application:start(public_key),
|
||||
application:start(ssl),
|
||||
- inets:start(),
|
||||
- inets:start(httpc, [{profile, rebar}]),
|
||||
- set_httpc_options(),
|
||||
|
||||
%% Fetch and build deps required to build rebar3
|
||||
BaseDeps = [{providers, []}
|
||||
@@ -33,7 +30,6 @@ main(_Args) ->
|
||||
|
||||
setup_env(),
|
||||
os:putenv("REBAR_PROFILE", "bootstrap"),
|
||||
- rebar3:run(["update"]),
|
||||
{ok, State} = rebar3:run(["compile"]),
|
||||
reset_env(),
|
||||
os:putenv("REBAR_PROFILE", ""),
|
||||
@@ -71,33 +67,7 @@ fetch_and_compile({Name, ErlFirstFiles}, Deps) ->
|
||||
compile(Name, ErlFirstFiles).
|
||||
|
||||
fetch({pkg, Name, Vsn}, App) ->
|
||||
- Dir = filename:join([filename:absname("_build/default/lib/"), App]),
|
||||
- CDN = "https://s3.amazonaws.com/s3.hex.pm/tarballs",
|
||||
- Package = binary_to_list(<<Name/binary, "-", Vsn/binary, ".tar">>),
|
||||
- Url = string:join([CDN, Package], "/"),
|
||||
- case request(Url) of
|
||||
- {ok, Binary} ->
|
||||
- {ok, Contents} = extract(Binary),
|
||||
- ok = erl_tar:extract({binary, Contents}, [{cwd, Dir}, compressed]);
|
||||
- _ ->
|
||||
- io:format("Error: Unable to fetch package ~p ~p~n", [Name, Vsn])
|
||||
- end.
|
||||
-
|
||||
-extract(Binary) ->
|
||||
- {ok, Files} = erl_tar:extract({binary, Binary}, [memory]),
|
||||
- {"contents.tar.gz", Contents} = lists:keyfind("contents.tar.gz", 1, Files),
|
||||
- {ok, Contents}.
|
||||
-
|
||||
-request(Url) ->
|
||||
- case httpc:request(get, {Url, []},
|
||||
- [{relaxed, true}],
|
||||
- [{body_format, binary}],
|
||||
- rebar) of
|
||||
- {ok, {{_Version, 200, _Reason}, _Headers, Body}} ->
|
||||
- {ok, Body};
|
||||
- Error ->
|
||||
- Error
|
||||
- end.
|
||||
+ ok.
|
||||
|
||||
get_rebar_config() ->
|
||||
{ok, [[Home]]} = init:get_argument(home),
|
||||
@@ -109,20 +79,6 @@ get_rebar_config() ->
|
||||
[]
|
||||
end.
|
||||
|
||||
-get_http_vars(Scheme) ->
|
||||
- proplists:get_value(Scheme, get_rebar_config(), []).
|
||||
-
|
||||
-set_httpc_options() ->
|
||||
- set_httpc_options(https_proxy, get_http_vars(https_proxy)),
|
||||
- set_httpc_options(proxy, get_http_vars(http_proxy)).
|
||||
-
|
||||
-set_httpc_options(_, []) ->
|
||||
- ok;
|
||||
-
|
||||
-set_httpc_options(Scheme, Proxy) ->
|
||||
- {ok, {_, _, Host, Port, _, _}} = http_uri:parse(Proxy),
|
||||
- httpc:set_options([{Scheme, {{Host, Port}, []}}], rebar).
|
||||
-
|
||||
compile(App, FirstFiles) ->
|
||||
Dir = filename:join(filename:absname("_build/default/lib/"), App),
|
||||
filelib:ensure_dir(filename:join([Dir, "ebin", "dummy.beam"])),
|
||||
@@ -0,0 +1,8 @@
|
||||
{ fetchFromGitHub }:
|
||||
|
||||
fetchFromGitHub {
|
||||
owner = "gleber";
|
||||
repo = "hex-pm-registry-snapshots";
|
||||
rev = "329ae2b";
|
||||
sha256 = "1rs3z8psfvy10mzlfvkdzbflgikcnq08r38kfi0f8p5wvi8f8hmh";
|
||||
}
|
||||
Reference in New Issue
Block a user