Merge remote-tracking branch 'upstream/master' into staging
This commit is contained in:
@@ -5,7 +5,7 @@ buildPythonApplication (rec {
|
||||
namePrefix = "";
|
||||
|
||||
src = fetchurl {
|
||||
url = "https://pypi.python.org/packages/source/b/buildbot-slave/${name}.tar.gz";
|
||||
url = "mirror://pypi/b/buildbot-slave/${name}.tar.gz";
|
||||
sha256 = "09pncw44c7vqrl7zyn1nvfismiqi9s51axk9cqxn9gq7jhj38mpg";
|
||||
};
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ buildPythonApplication (rec {
|
||||
namePrefix = "";
|
||||
|
||||
src = fetchurl {
|
||||
url = "https://pypi.python.org/packages/source/b/buildbot/${name}.tar.gz";
|
||||
url = "mirror://pypi/b/buildbot/${name}.tar.gz";
|
||||
sha256 = "1mn4h04sp6smr3ahqfflys15cpn13q9mfkapcs2jc4ppvxv6kdn6";
|
||||
};
|
||||
|
||||
|
||||
@@ -1,73 +1,62 @@
|
||||
{ stdenv, writeText, callPackage, fetchurl,
|
||||
fetchHex, erlang, hermeticRebar3 ? true, rebar3-nix-bootstrap, tree, fetchFromGitHub }:
|
||||
|
||||
fetchHex, erlang, hermeticRebar3 ? true,
|
||||
tree, fetchFromGitHub, hexRegistrySnapshot }:
|
||||
|
||||
let
|
||||
version = "3.0.0-beta.4";
|
||||
registrySnapshot = callPackage ./registrySnapshot.nix { };
|
||||
version = "3.1.0";
|
||||
|
||||
bootstrapper = ./rebar3-nix-bootstrap;
|
||||
|
||||
# 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";
|
||||
version = "0.19.0";
|
||||
sha256 = "1gfsy9bbhjb94c5ghff2niamn93x2x08lnklh6pp7sfr5i0gkgsv";
|
||||
};
|
||||
# {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";
|
||||
version = "0.4.0";
|
||||
sha256 = "04bnvsbssdcf6b9h9bfglflds7j0gx6q5igl1xxhx6fnwaz37hhw";
|
||||
};
|
||||
# {providers, "1.5.0"},
|
||||
providers = fetchHex {
|
||||
pkg = "providers";
|
||||
version = "1.5.0";
|
||||
sha256 = "1hc8sp2l1mmx9dfpmh1f8j9hayfg7541rmx05wb9cmvxvih7zyvf";
|
||||
version = "1.6.0";
|
||||
sha256 = "0byfa1h57n46jilz4q132j0vk3iqc0v1vip89li38gb1k997cs0g";
|
||||
};
|
||||
# {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";
|
||||
version = "3.17.0";
|
||||
sha256 = "1xjybi93m8gj9f9z3lkc7xbg3k5cw56yl78rcz5qfirr0223sby2";
|
||||
};
|
||||
# {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";
|
||||
version = "1.2.2";
|
||||
sha256 = "0kb9v4998liwyidpjkhcg1nin6djjzxcx6b313pbjicbp4r58n3p";
|
||||
};
|
||||
# {eunit_formatters, "0.2.0"}
|
||||
eunit_formatters = fetchHex {
|
||||
pkg = "eunit_formatters";
|
||||
version = "0.2.0";
|
||||
sha256 = "03kiszlbgzscfd2ns7na6bzbfzmcqdb5cx3p6qy3657jk2fai332";
|
||||
version = "0.3.1";
|
||||
sha256 = "0cg9dasv60v09q3q4wja76pld0546mhmlpb0khagyylv890hg934";
|
||||
};
|
||||
# {eunit_formatters, "0.2.0"}
|
||||
rebar3_hex = fetchHex {
|
||||
pkg = "rebar3_hex";
|
||||
version = "1.12.0";
|
||||
@@ -81,19 +70,21 @@ stdenv.mkDerivation {
|
||||
|
||||
src = fetchurl {
|
||||
url = "https://github.com/rebar/rebar3/archive/${version}.tar.gz";
|
||||
sha256 = "0px66scjdia9aaa5z36qzxb848r56m0k98g0bxw065a2narsh4xy";
|
||||
sha256 = "0r4wpnpi81ha4iirv9hcif3vrgc82qd51kah7rnhvpym55wcy9ml";
|
||||
};
|
||||
|
||||
inherit bootstrapper;
|
||||
|
||||
patches = if hermeticRebar3 == true
|
||||
then [ ./hermetic-bootstrap.patch ./hermetic-rebar3.patch ]
|
||||
else [];
|
||||
|
||||
buildInputs = [ erlang tree ];
|
||||
propagatedBuildInputs = [ registrySnapshot rebar3-nix-bootstrap ];
|
||||
propagatedBuildInputs = [ hexRegistrySnapshot ];
|
||||
|
||||
postPatch = ''
|
||||
echo postPatch
|
||||
rebar3-nix-bootstrap registry-only
|
||||
${erlang}/bin/escript ${bootstrapper} registry-only
|
||||
echo "$ERL_LIBS"
|
||||
mkdir -p _build/default/lib/
|
||||
mkdir -p _build/default/plugins
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
{ 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;
|
||||
})
|
||||
@@ -1,39 +1,61 @@
|
||||
diff --git a/bootstrap b/bootstrap
|
||||
index 25bd658..b2a986b 100755
|
||||
index 35759b0..939c838 100755
|
||||
--- a/bootstrap
|
||||
+++ b/bootstrap
|
||||
@@ -8,9 +8,6 @@ main(_Args) ->
|
||||
@@ -7,9 +7,11 @@ main(_) ->
|
||||
application:start(asn1),
|
||||
application:start(public_key),
|
||||
application:start(ssl),
|
||||
- inets:start(),
|
||||
- inets:start(httpc, [{profile, rebar}]),
|
||||
- set_httpc_options(),
|
||||
|
||||
+ %% Removed for hermeticity on Nix
|
||||
+ %%
|
||||
+ %% 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) ->
|
||||
@@ -74,12 +76,12 @@ default_registry_file() ->
|
||||
filename:join([CacheDir, "hex", "default", "registry"]).
|
||||
|
||||
fetch_and_compile({Name, ErlFirstFiles}, Deps) ->
|
||||
- case lists:keyfind(Name, 1, Deps) of
|
||||
- {Name, Vsn} ->
|
||||
- ok = fetch({pkg, atom_to_binary(Name, utf8), list_to_binary(Vsn)}, Name);
|
||||
- {Name, _, Source} ->
|
||||
- ok = fetch(Source, Name)
|
||||
- end,
|
||||
+ %% case lists:keyfind(Name, 1, Deps) of
|
||||
+ %% {Name, Vsn} ->
|
||||
+ %% ok = fetch({pkg, atom_to_binary(Name, utf8), list_to_binary(Vsn)}, Name);
|
||||
+ %% {Name, _, Source} ->
|
||||
+ %% ok = fetch(Source, Name)
|
||||
+ %% end,
|
||||
|
||||
%% Hack: erlware_commons depends on a .script file to check if it is being built with
|
||||
%% rebar2 or rebar3. But since rebar3 isn't built yet it can't get the vsn with get_key.
|
||||
@@ -88,63 +90,63 @@ fetch_and_compile({Name, ErlFirstFiles}, Deps) ->
|
||||
|
||||
compile(Name, ErlFirstFiles).
|
||||
|
||||
fetch({pkg, Name, Vsn}, App) ->
|
||||
|
||||
-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])
|
||||
- case filelib:is_dir(Dir) of
|
||||
- false ->
|
||||
- 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;
|
||||
- true ->
|
||||
- io:format("Dependency ~s already exists~n", [Name])
|
||||
- end.
|
||||
-
|
||||
-extract(Binary) ->
|
||||
@@ -51,14 +73,17 @@ index 25bd658..b2a986b 100755
|
||||
- Error ->
|
||||
- Error
|
||||
- end.
|
||||
+ ok.
|
||||
|
||||
get_rebar_config() ->
|
||||
{ok, [[Home]]} = init:get_argument(home),
|
||||
@@ -109,20 +79,6 @@ get_rebar_config() ->
|
||||
[]
|
||||
end.
|
||||
|
||||
-
|
||||
-get_rebar_config() ->
|
||||
- {ok, [[Home]]} = init:get_argument(home),
|
||||
- ConfDir = filename:join(Home, ".config/rebar3"),
|
||||
- case file:consult(filename:join(ConfDir, "rebar.config")) of
|
||||
- {ok, Config} ->
|
||||
- Config;
|
||||
- _ ->
|
||||
- []
|
||||
- end.
|
||||
-
|
||||
-get_http_vars(Scheme) ->
|
||||
- proplists:get_value(Scheme, get_rebar_config(), []).
|
||||
-
|
||||
@@ -72,7 +97,63 @@ index 25bd658..b2a986b 100755
|
||||
-set_httpc_options(Scheme, Proxy) ->
|
||||
- {ok, {_, _, Host, Port, _, _}} = http_uri:parse(Proxy),
|
||||
- httpc:set_options([{Scheme, {{Host, Port}, []}}], rebar).
|
||||
-
|
||||
+%% fetch({pkg, Name, Vsn}, App) ->
|
||||
+%% Dir = filename:join([filename:absname("_build/default/lib/"), App]),
|
||||
+%% case filelib:is_dir(Dir) of
|
||||
+%% false ->
|
||||
+%% 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;
|
||||
+%% true ->
|
||||
+%% io:format("Dependency ~s already exists~n", [Name])
|
||||
+%% 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.
|
||||
+
|
||||
+%% get_rebar_config() ->
|
||||
+%% {ok, [[Home]]} = init:get_argument(home),
|
||||
+%% ConfDir = filename:join(Home, ".config/rebar3"),
|
||||
+%% case file:consult(filename:join(ConfDir, "rebar.config")) of
|
||||
+%% {ok, Config} ->
|
||||
+%% 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"])),
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
diff --git a/src/rebar3.erl b/src/rebar3.erl
|
||||
index 2b73844..af1d871 100644
|
||||
diff a/src/rebar3.erl b/src/rebar3.erl
|
||||
index c1a1ae4..1bf1ea0 100644
|
||||
--- a/src/rebar3.erl
|
||||
+++ b/src/rebar3.erl
|
||||
@@ -282,9 +282,11 @@ start_and_load_apps(Caller) ->
|
||||
@@ -294,9 +294,11 @@ start_and_load_apps(Caller) ->
|
||||
ensure_running(crypto, Caller),
|
||||
ensure_running(asn1, Caller),
|
||||
ensure_running(public_key, Caller),
|
||||
@@ -10,21 +10,14 @@ index 2b73844..af1d871 100644
|
||||
- inets:start(),
|
||||
- inets:start(httpc, [{profile, rebar}]).
|
||||
+ ensure_running(ssl, Caller).
|
||||
+%% Removed due to the hermicity requirements of Nix
|
||||
+%% Removed due to the hermicity requirements of Nix
|
||||
+%%
|
||||
+%% inets:start(),
|
||||
+%% inets:start(httpc, [{profile, rebar}]).
|
||||
|
||||
|
||||
ensure_running(App, Caller) ->
|
||||
case application:start(App) of
|
||||
@@ -339,4 +341,4 @@ safe_define_test_macro(Opts) ->
|
||||
test_defined([{d, 'TEST'}|_]) -> true;
|
||||
test_defined([{d, 'TEST', true}|_]) -> true;
|
||||
test_defined([_|Rest]) -> test_defined(Rest);
|
||||
-test_defined([]) -> false.
|
||||
\ No newline at end of file
|
||||
+test_defined([]) -> false.
|
||||
diff --git a/src/rebar_hermicity.erl b/src/rebar_hermicity.erl
|
||||
diff a/src/rebar_hermicity.erl b/src/rebar_hermicity.erl
|
||||
new file mode 100644
|
||||
index 0000000..d814e2a
|
||||
--- /dev/null
|
||||
@@ -72,37 +65,29 @@ index 0000000..d814e2a
|
||||
+ "are as follows:", []),
|
||||
+ ?ERROR("Requesnt: ~p ~s", [Method, Url]),
|
||||
+ erlang:halt(1).
|
||||
diff --git a/src/rebar_pkg_resource.erl b/src/rebar_pkg_resource.erl
|
||||
index 4f55ad1..f76fd5d 100644
|
||||
diff a/src/rebar_pkg_resource.erl b/src/rebar_pkg_resource.erl
|
||||
index ec7e09d..03be343 100644
|
||||
--- a/src/rebar_pkg_resource.erl
|
||||
+++ b/src/rebar_pkg_resource.erl
|
||||
@@ -100,10 +100,10 @@ make_vsn(_) ->
|
||||
@@ -104,7 +104,7 @@ make_vsn(_) ->
|
||||
{error, "Replacing version of type pkg not supported."}.
|
||||
|
||||
|
||||
request(Url, ETag) ->
|
||||
- case httpc:request(get, {Url, [{"if-none-match", ETag} || ETag =/= false]},
|
||||
- [{ssl, ssl_opts(Url)}, {relaxed, true}],
|
||||
- [{body_format, binary}],
|
||||
- rebar) of
|
||||
+ case rebar_hermicity:request(get, {Url, [{"if-none-match", ETag} || ETag =/= false]},
|
||||
+ [{ssl, ssl_opts(Url)}, {relaxed, true}],
|
||||
+ [{body_format, binary}],
|
||||
+ rebar) of
|
||||
{ok, {{_Version, 200, _Reason}, Headers, Body}} ->
|
||||
?DEBUG("Successfully downloaded ~s", [Url]),
|
||||
{"etag", ETag1} = lists:keyfind("etag", 1, Headers),
|
||||
diff --git a/src/rebar_prv_update.erl b/src/rebar_prv_update.erl
|
||||
index 6637ebe..d82c1d8 100644
|
||||
- case httpc:request(get, {Url, [{"if-none-match", ETag} || ETag =/= false]++[{"User-Agent", rebar_utils:user_agent()}]},
|
||||
+ case rebar_hermicity:request(get, {Url, [{"if-none-match", ETag} || ETag =/= false]++[{"User-Agent", rebar_utils:user_agent()}]},
|
||||
[{ssl, ssl_opts(Url)}, {relaxed, true}],
|
||||
[{body_format, binary}],
|
||||
rebar) of
|
||||
diff a/src/rebar_prv_update.erl b/src/rebar_prv_update.erl
|
||||
index 5e1e253..ea25b9e 100644
|
||||
--- a/src/rebar_prv_update.erl
|
||||
+++ b/src/rebar_prv_update.erl
|
||||
@@ -44,8 +44,8 @@ do(State) ->
|
||||
TmpFile = filename:join(TmpDir, "packages.gz"),
|
||||
|
||||
Url = rebar_state:get(State, rebar_packages_cdn, ?DEFAULT_HEX_REGISTRY),
|
||||
- case httpc:request(get, {Url, []},
|
||||
- [], [{stream, TmpFile}, {sync, true}],
|
||||
+ case rebar_hermicity:request(get, {Url, []},
|
||||
+ [], [{stream, TmpFile}, {sync, true}],
|
||||
rebar) of
|
||||
{ok, saved_to_file} ->
|
||||
{ok, Data} = file:read_file(TmpFile),
|
||||
@@ -52,7 +52,7 @@ do(State) ->
|
||||
case rebar_utils:url_append_path(CDN, ?REMOTE_REGISTRY_FILE) of
|
||||
{ok, Url} ->
|
||||
?DEBUG("Fetching registry from ~p", [Url]),
|
||||
- case httpc:request(get, {Url, [{"User-Agent", rebar_utils:user_agent()}]},
|
||||
+ case rebar_hermicity:request(get, {Url, [{"User-Agent", rebar_utils:user_agent()}]},
|
||||
[], [{stream, TmpFile}, {sync, true}],
|
||||
rebar) of
|
||||
{ok, saved_to_file} ->
|
||||
|
||||
255
pkgs/development/tools/build-managers/rebar3/rebar3-nix-bootstrap
Executable file
255
pkgs/development/tools/build-managers/rebar3/rebar3-nix-bootstrap
Executable file
@@ -0,0 +1,255 @@
|
||||
#!/usr/bin/env escript
|
||||
%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
|
||||
%%! -smp enable
|
||||
%%% ---------------------------------------------------------------------------
|
||||
%%% @doc
|
||||
%%% The purpose of this command is to prepare a rebar3 project so that
|
||||
%%% rebar3 understands that the dependencies are all already
|
||||
%%% installed. If you want a hygienic build on nix then you must run
|
||||
%%% this command before running rebar3. I suggest that you add a
|
||||
%%% `Makefile` to your project and have the bootstrap command be a
|
||||
%%% dependency of the build commands. See the nix documentation for
|
||||
%%% more information.
|
||||
%%%
|
||||
%%% This command designed to have as few dependencies as possible so
|
||||
%%% that it can be a dependency of root level packages like rebar3. To
|
||||
%%% that end it does many things in a fairly simplistic way. That is
|
||||
%%% by design.
|
||||
%%%
|
||||
%%% ### Assumptions
|
||||
%%%
|
||||
%%% This command makes the following assumptions:
|
||||
%%%
|
||||
%%% * It is run in a nix-shell or nix-build environment
|
||||
%%% * that all dependencies have been added to the ERL_LIBS
|
||||
%%% Environment Variable
|
||||
|
||||
-record(data, {version
|
||||
, registry_only = false
|
||||
, compile_ports
|
||||
, erl_libs
|
||||
, plugins
|
||||
, root
|
||||
, name
|
||||
, registry_snapshot}).
|
||||
|
||||
-define(HEX_REGISTRY_PATH, ".cache/rebar3/hex/default/registry").
|
||||
|
||||
main(Args) ->
|
||||
{ok, ArgData} = parse_args(Args),
|
||||
{ok, RequiredData} = gather_required_data_from_the_environment(ArgData),
|
||||
do_the_bootstrap(RequiredData).
|
||||
|
||||
%% @doc There are two modes 'registery_only' where the register is
|
||||
%% created from hex and everything else.
|
||||
-spec do_the_bootstrap(#data{}) -> ok.
|
||||
do_the_bootstrap(RequiredData = #data{registry_only = true}) ->
|
||||
ok = bootstrap_registry(RequiredData);
|
||||
do_the_bootstrap(RequiredData) ->
|
||||
ok = bootstrap_registry(RequiredData),
|
||||
ok = bootstrap_configs(RequiredData),
|
||||
ok = bootstrap_plugins(RequiredData),
|
||||
ok = bootstrap_libs(RequiredData).
|
||||
|
||||
%% @doc
|
||||
%% Argument parsing is super simple only because we want to keep the
|
||||
%% dependencies minimal. For now there can be two entries on the
|
||||
%% command line, "registery-only"
|
||||
-spec parse_args([string()]) -> #data{}.
|
||||
parse_args(["registry-only"]) ->
|
||||
{ok, #data{registry_only = true}};
|
||||
parse_args([]) ->
|
||||
{ok, #data{registry_only = false}};
|
||||
parse_args(Args) ->
|
||||
io:format("Unexpected command line arguments passed in: ~p~n", [Args]),
|
||||
erlang:halt(120).
|
||||
|
||||
-spec bootstrap_configs(#data{}) -> ok.
|
||||
bootstrap_configs(RequiredData)->
|
||||
io:format("Boostrapping app and rebar configurations~n"),
|
||||
ok = if_single_app_project_update_app_src_version(RequiredData),
|
||||
ok = if_compile_ports_add_pc_plugin(RequiredData).
|
||||
|
||||
-spec bootstrap_plugins(#data{}) -> ok.
|
||||
bootstrap_plugins(#data{plugins = Plugins}) ->
|
||||
io:format("Bootstrapping rebar3 plugins~n"),
|
||||
Target = "_build/default/plugins/",
|
||||
Paths = string:tokens(Plugins, " "),
|
||||
CopiableFiles =
|
||||
lists:foldl(fun(Path, Acc) ->
|
||||
gather_dependency(Path) ++ Acc
|
||||
end, [], Paths),
|
||||
lists:foreach(fun (Path) ->
|
||||
ok = link_app(Path, Target)
|
||||
end, CopiableFiles).
|
||||
|
||||
-spec bootstrap_libs(#data{}) -> ok.
|
||||
bootstrap_libs(#data{erl_libs = ErlLibs}) ->
|
||||
io:format("Bootstrapping dependent librariesXXXX~n"),
|
||||
Target = "_build/default/lib/",
|
||||
Paths = string:tokens(ErlLibs, ":"),
|
||||
CopiableFiles =
|
||||
lists:foldl(fun(Path, Acc) ->
|
||||
gather_directory_contents(Path) ++ Acc
|
||||
end, [], Paths),
|
||||
lists:foreach(fun (Path) ->
|
||||
ok = link_app(Path, Target)
|
||||
end, CopiableFiles).
|
||||
|
||||
-spec gather_dependency(string()) -> [{string(), string()}].
|
||||
gather_dependency(Path) ->
|
||||
FullLibrary = filename:join(Path, "lib/erlang/lib/"),
|
||||
case filelib:is_dir(FullLibrary) of
|
||||
true ->
|
||||
gather_directory_contents(FullLibrary);
|
||||
false ->
|
||||
[raw_hex(Path)]
|
||||
end.
|
||||
|
||||
-spec raw_hex(string()) -> {string(), string()}.
|
||||
raw_hex(Path) ->
|
||||
[_, Name] = re:split(Path, "-hex-source-"),
|
||||
{Path, erlang:binary_to_list(Name)}.
|
||||
|
||||
-spec gather_directory_contents(string()) -> [{string(), string()}].
|
||||
gather_directory_contents(Path) ->
|
||||
{ok, Names} = file:list_dir(Path),
|
||||
lists:map(fun(AppName) ->
|
||||
{filename:join(Path, AppName), fixup_app_name(AppName)}
|
||||
end, Names).
|
||||
|
||||
%% @doc
|
||||
%% Makes a symlink from the directory pointed at by Path to a
|
||||
%% directory of the same name in Target. So if we had a Path of
|
||||
%% {`foo/bar/baz/bash`, `baz`} and a Target of `faz/foo/foos`, the symlink
|
||||
%% would be `faz/foo/foos/baz`.
|
||||
-spec link_app({string(), string()}, string()) -> ok.
|
||||
link_app({Path, TargetFile}, TargetDir) ->
|
||||
Target = filename:join(TargetDir, TargetFile),
|
||||
make_symlink(Path, Target).
|
||||
|
||||
-spec make_symlink(string(), string()) -> ok.
|
||||
make_symlink(Path, TargetFile) ->
|
||||
file:delete(TargetFile),
|
||||
ok = filelib:ensure_dir(TargetFile),
|
||||
io:format("Making symlink from ~s to ~s~n", [Path, TargetFile]),
|
||||
ok = file:make_symlink(Path, TargetFile).
|
||||
|
||||
%% @doc
|
||||
%% This takes an app name in the standard OTP <name>-<version> format
|
||||
%% and returns just the app name. Why? because rebar is doesn't
|
||||
%% respect OTP conventions in some cases.
|
||||
-spec fixup_app_name(string()) -> string().
|
||||
fixup_app_name(FileName) ->
|
||||
case string:tokens(FileName, "-") of
|
||||
[Name] -> Name;
|
||||
[Name, _Version] -> Name
|
||||
end.
|
||||
|
||||
-spec bootstrap_registry(#data{}) -> ok.
|
||||
bootstrap_registry(#data{registry_snapshot = RegistrySnapshot}) ->
|
||||
io:format("Bootstrapping Hex Registry for Rebar~n"),
|
||||
make_sure_registry_snapshot_exists(RegistrySnapshot),
|
||||
filelib:ensure_dir(?HEX_REGISTRY_PATH),
|
||||
ok = case filelib:is_file(?HEX_REGISTRY_PATH) of
|
||||
true ->
|
||||
file:delete(?HEX_REGISTRY_PATH);
|
||||
false ->
|
||||
ok
|
||||
end,
|
||||
ok = file:make_symlink(RegistrySnapshot,
|
||||
?HEX_REGISTRY_PATH).
|
||||
|
||||
-spec make_sure_registry_snapshot_exists(string()) -> ok.
|
||||
make_sure_registry_snapshot_exists(RegistrySnapshot) ->
|
||||
case filelib:is_file(RegistrySnapshot) of
|
||||
true ->
|
||||
ok;
|
||||
false ->
|
||||
stderr("Registry snapshot (~s) does not exist!", [RegistrySnapshot]),
|
||||
erlang:halt(1)
|
||||
end.
|
||||
|
||||
-spec gather_required_data_from_the_environment(#data{}) -> {ok, map()}.
|
||||
gather_required_data_from_the_environment(ArgData) ->
|
||||
{ok, ArgData#data{ version = guard_env("version")
|
||||
, erl_libs = os:getenv("ERL_LIBS", [])
|
||||
, plugins = os:getenv("buildPlugins", [])
|
||||
, root = code:root_dir()
|
||||
, name = guard_env("name")
|
||||
, compile_ports = nix2bool(os:getenv("compilePorts", ""))
|
||||
, registry_snapshot = guard_env("HEX_REGISTRY_SNAPSHOT")}}.
|
||||
|
||||
-spec nix2bool(any()) -> boolean().
|
||||
nix2bool("1") ->
|
||||
true;
|
||||
nix2bool("") ->
|
||||
false.
|
||||
|
||||
-spec guard_env(string()) -> string().
|
||||
guard_env(Name) ->
|
||||
case os:getenv(Name) of
|
||||
false ->
|
||||
stderr("Expected Environment variable ~s! Are you sure you are "
|
||||
"running in a Nix environment? Either a nix-build, "
|
||||
"nix-shell, etc?~n", [Name]),
|
||||
erlang:halt(1);
|
||||
Variable ->
|
||||
Variable
|
||||
end.
|
||||
|
||||
%% @doc
|
||||
%% If the compile ports flag is set, rewrite the rebar config to
|
||||
%% include the 'pc' plugin.
|
||||
-spec if_compile_ports_add_pc_plugin(#data{}) -> ok.
|
||||
if_compile_ports_add_pc_plugin(#data{compile_ports = true}) ->
|
||||
ConfigTerms = add_pc_to_plugins(read_rebar_config()),
|
||||
Text = lists:map(fun(Term) -> io_lib:format("~tp.~n", [Term]) end,
|
||||
ConfigTerms),
|
||||
file:write_file("rebar.config", Text);
|
||||
if_compile_ports_add_pc_plugin(_) ->
|
||||
ok.
|
||||
|
||||
-spec add_pc_to_plugins([term()]) -> [term()].
|
||||
add_pc_to_plugins(Config) ->
|
||||
PluginList = case lists:keysearch(plugins, 1, Config) of
|
||||
{ok, {plugins, ExistingPluginList}} -> ExistingPluginList;
|
||||
_ -> []
|
||||
end,
|
||||
lists:keystore(plugins, 1, Config, {plugins, [pc | PluginList]}).
|
||||
|
||||
-spec read_rebar_config() -> [term()].
|
||||
read_rebar_config() ->
|
||||
case file:consult("rebar.config") of
|
||||
{ok, Terms} ->
|
||||
Terms;
|
||||
_ ->
|
||||
stderr("Unable to read rebar config!", []),
|
||||
erlang:halt(1)
|
||||
end.
|
||||
|
||||
|
||||
-spec if_single_app_project_update_app_src_version(#data{}) -> ok.
|
||||
if_single_app_project_update_app_src_version(#data{name = Name,
|
||||
version = Version}) ->
|
||||
SrcFile = filename:join("src",
|
||||
lists:concat([Name, ".app.src"])),
|
||||
|
||||
case filelib:is_file(SrcFile) of
|
||||
true ->
|
||||
update_app_src_with_version(SrcFile, Version);
|
||||
false ->
|
||||
ok
|
||||
end.
|
||||
|
||||
-spec update_app_src_with_version(string(), string()) -> ok.
|
||||
update_app_src_with_version(SrcFile, Version) ->
|
||||
{ok, [{application, Name, Details}]} = file:consult(SrcFile),
|
||||
NewDetails = lists:keyreplace(vsn, 1, Details, {vsn, Version}),
|
||||
ok = file:write_file(SrcFile, io_lib:fwrite("~p.\n", [{application, Name, NewDetails}])).
|
||||
|
||||
%% @doc
|
||||
%% Write the result of the format string out to stderr.
|
||||
-spec stderr(string(), [term()]) -> ok.
|
||||
stderr(FormatStr, Args) ->
|
||||
io:put_chars(standard_error, io_lib:format(FormatStr, Args)).
|
||||
@@ -5,7 +5,7 @@ pythonPackages.buildPythonApplication rec {
|
||||
version = "2.3.2";
|
||||
|
||||
src = fetchurl {
|
||||
url = "https://pypi.python.org/packages/source/d/devpi-client/devpi-client-${version}.tar.gz";
|
||||
url = "mirror://pypi/d/devpi-client/devpi-client-${version}.tar.gz";
|
||||
md5= "bfc8cd768f983fd0585c347bca00c8bb";
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{stdenv, autoconf, which, writeText, makeWrapper, fetchFromGitHub, erlang,
|
||||
erlangPackages, z3, python27 }:
|
||||
beamPackages, z3, python27 }:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
name = "cuter";
|
||||
@@ -13,9 +13,9 @@ stdenv.mkDerivation rec {
|
||||
};
|
||||
|
||||
setupHook = writeText "setupHook.sh" ''
|
||||
addToSearchPath ERL_LIBS "$1/lib/erlang/lib/"
|
||||
addToSearchPath ERL_LIBS "$1/lib/erlang/lib/"
|
||||
'';
|
||||
buildInputs = with erlangPackages; [ autoconf erlang z3 python27 makeWrapper which ];
|
||||
buildInputs = with beamPackages; [ autoconf erlang z3 python27 makeWrapper which ];
|
||||
|
||||
buildFlags = "PWD=$(out)/lib/erlang/lib/cuter-${version} cuter_target";
|
||||
configurePhase = ''
|
||||
|
||||
@@ -2,16 +2,16 @@
|
||||
|
||||
buildRebar3 rec {
|
||||
name = "hex2nix";
|
||||
version = "0.0.3";
|
||||
version = "0.0.5";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "erlang-nix";
|
||||
repo = "hex2nix";
|
||||
rev = "${version}";
|
||||
sha256 = "1snlcb60al7fz3z4c4rqrb9gqdyihyhsrr90n40v9rdm98csry3k";
|
||||
};
|
||||
owner = "erlang-nix";
|
||||
repo = "hex2nix";
|
||||
rev = "${version}";
|
||||
sha256 = "07bk18nib4xms8q1i4sv53drvlyllm47map4c95669lsh0j08sax";
|
||||
};
|
||||
|
||||
erlangDeps = [ ibrowse jsx erlware_commons getopt ];
|
||||
beamDeps = [ ibrowse jsx erlware_commons getopt ];
|
||||
|
||||
DEBUG=1;
|
||||
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
{stdenv, fetchFromGitHub, erlang }:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
name = "rebar3-nix-bootstrap";
|
||||
version = "0.0.3";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "erlang-nix";
|
||||
repo = "rebar3-nix-bootstrap";
|
||||
rev = "${version}";
|
||||
sha256 = "01yyaz104jj3mxx8k10q3rwpn2rh13q1ja5r0iq37qyjmg8xflhq";
|
||||
};
|
||||
|
||||
buildInputs = [ erlang ];
|
||||
|
||||
installFlags = "PREFIX=$(out)";
|
||||
|
||||
meta = {
|
||||
description = "Shim command to help bootstrap a rebar3 project on Nix";
|
||||
license = stdenv.lib.licenses.asl20;
|
||||
homepage = "https://github.com/erlang-nix/rebar3-nix-bootstrap";
|
||||
maintainers = with stdenv.lib.maintainers; [ ericbmerritt ];
|
||||
};
|
||||
}
|
||||
38
pkgs/development/tools/erlang/relx-exe/default.nix
Normal file
38
pkgs/development/tools/erlang/relx-exe/default.nix
Normal file
@@ -0,0 +1,38 @@
|
||||
{ stdenv, beamPackages, makeWrapper, fetchHex, erlang }:
|
||||
beamPackages.buildRebar3 {
|
||||
name = "relx-exe";
|
||||
version = "3.18.0";
|
||||
src = fetchHex {
|
||||
pkg = "relx";
|
||||
version = "3.18.0";
|
||||
sha256 =
|
||||
"e76e0446b8d1b113f2b7dcc713f032ccdf1dbda33d76edfeb19c2b6b686dcad7";
|
||||
};
|
||||
|
||||
buildInputs = [ makeWrapper erlang ];
|
||||
|
||||
beamDeps = with beamPackages; [
|
||||
providers_1_6_0
|
||||
getopt_0_8_2
|
||||
erlware_commons_0_19_0
|
||||
cf_0_2_1
|
||||
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 ];
|
||||
};
|
||||
|
||||
}
|
||||
49
pkgs/development/tools/misc/autoconf/2.64.nix
Normal file
49
pkgs/development/tools/misc/autoconf/2.64.nix
Normal file
@@ -0,0 +1,49 @@
|
||||
{ stdenv, fetchurl, m4, perl }:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
name = "autoconf-2.64";
|
||||
|
||||
src = fetchurl {
|
||||
url = "mirror://gnu/autoconf/${name}.tar.xz";
|
||||
sha256 = "0j3jdjpf5ly39dlp0bg70h72nzqr059k0x8iqxvaxf106chpgn9j";
|
||||
};
|
||||
|
||||
buildInputs = [ m4 perl ];
|
||||
|
||||
# Work around a known issue in Cygwin. See
|
||||
# http://thread.gmane.org/gmane.comp.sysutils.autoconf.bugs/6822 for
|
||||
# details.
|
||||
# There are many test failures on `i386-pc-solaris2.11'.
|
||||
#doCheck = ((!stdenv.isCygwin) && (!stdenv.isSunOS));
|
||||
doCheck = false;
|
||||
|
||||
# Don't fixup "#! /bin/sh" in Autoconf, otherwise it will use the
|
||||
# "fixed" path in generated files!
|
||||
dontPatchShebangs = true;
|
||||
|
||||
enableParallelBuilding = true;
|
||||
|
||||
preCheck =
|
||||
# Make the Autotest test suite run in parallel.
|
||||
'' export TESTSUITEFLAGS="-j$NIX_BUILD_CORES"
|
||||
'';
|
||||
|
||||
meta = {
|
||||
homepage = http://www.gnu.org/software/autoconf/;
|
||||
description = "Part of the GNU Build System";
|
||||
|
||||
longDescription = ''
|
||||
GNU Autoconf is an extensible package of M4 macros that produce
|
||||
shell scripts to automatically configure software source code
|
||||
packages. These scripts can adapt the packages to many kinds of
|
||||
UNIX-like systems without manual user intervention. Autoconf
|
||||
creates a configuration script for a package from a template
|
||||
file that lists the operating system features that the package
|
||||
can use, in the form of M4 macro calls.
|
||||
'';
|
||||
|
||||
license = stdenv.lib.licenses.gpl2Plus;
|
||||
|
||||
platforms = stdenv.lib.platforms.all;
|
||||
};
|
||||
}
|
||||
@@ -16,13 +16,15 @@ stdenv.mkDerivation rec {
|
||||
};
|
||||
|
||||
unpackPhase = "tar xvjf $src; cd lsof_*; tar xvf lsof_*.tar; sourceRoot=$( echo lsof_*/); ";
|
||||
|
||||
|
||||
preBuild = "sed -i Makefile -e 's/^CFGF=/& -DHASIPv6=1/;';";
|
||||
|
||||
configurePhase = if stdenv.isDarwin
|
||||
then "./Configure -n darwin;"
|
||||
else "./Configure -n linux;";
|
||||
|
||||
|
||||
configurePhase = ''
|
||||
# Stop build scripts from searching global include paths
|
||||
export LSOF_INCLUDE=/$(md5sum <(echo $name) | awk '{print $1}')
|
||||
./Configure -n ${if stdenv.isDarwin then "darwin" else "linux"}
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin $out/man/man8
|
||||
cp lsof.8 $out/man/man8/
|
||||
|
||||
Reference in New Issue
Block a user