buildRebar3: use rebar3WithPlugins
This commit is contained in:
parent
aaa16732ce
commit
dcc075ce21
@ -1,4 +1,4 @@
|
|||||||
{ stdenv, writeText, erlang, rebar3, openssl, libyaml,
|
{ stdenv, writeText, erlang, rebar3WithPlugins, openssl, libyaml,
|
||||||
pc, lib }:
|
pc, lib }:
|
||||||
|
|
||||||
{ name, version
|
{ name, version
|
||||||
@ -19,7 +19,10 @@ with lib;
|
|||||||
let
|
let
|
||||||
debugInfoFlag = lib.optionalString (enableDebugInfo || erlang.debugInfo) "debug-info";
|
debugInfoFlag = lib.optionalString (enableDebugInfo || erlang.debugInfo) "debug-info";
|
||||||
|
|
||||||
ownPlugins = buildPlugins ++ (if compilePorts then [pc] else []);
|
rebar3 = rebar3WithPlugins {
|
||||||
|
plugins = buildPlugins;
|
||||||
|
globalPlugins = (if compilePorts then [pc] else []);
|
||||||
|
};
|
||||||
|
|
||||||
shell = drv: stdenv.mkDerivation {
|
shell = drv: stdenv.mkDerivation {
|
||||||
name = "interactive-shell-${drv.name}";
|
name = "interactive-shell-${drv.name}";
|
||||||
@ -36,13 +39,9 @@ let
|
|||||||
inherit version;
|
inherit version;
|
||||||
|
|
||||||
buildInputs = buildInputs ++ [ erlang rebar3 openssl libyaml ];
|
buildInputs = buildInputs ++ [ erlang rebar3 openssl libyaml ];
|
||||||
propagatedBuildInputs = unique (beamDeps ++ ownPlugins);
|
propagatedBuildInputs = unique beamDeps;
|
||||||
|
|
||||||
dontStrip = true;
|
dontStrip = true;
|
||||||
# The following are used by rebar3-nix-bootstrap
|
|
||||||
inherit compilePorts;
|
|
||||||
buildPlugins = ownPlugins;
|
|
||||||
|
|
||||||
inherit src;
|
inherit src;
|
||||||
|
|
||||||
setupHook = writeText "setupHook.sh" ''
|
setupHook = writeText "setupHook.sh" ''
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
let
|
let
|
||||||
version = "3.15.1";
|
version = "3.15.1";
|
||||||
owner = "erlang";
|
owner = "erlang";
|
||||||
deps = import ./rebar-deps.nix { inherit fetchHex fetchFromGitHub; };
|
deps = import ./rebar-deps.nix { inherit fetchHex; };
|
||||||
rebar3 = stdenv.mkDerivation rec {
|
rebar3 = stdenv.mkDerivation rec {
|
||||||
pname = "rebar3";
|
pname = "rebar3";
|
||||||
inherit version erlang;
|
inherit version erlang;
|
||||||
|
@ -26,9 +26,7 @@
|
|||||||
|
|
||||||
-record(data, {version
|
-record(data, {version
|
||||||
, debug_info = false
|
, debug_info = false
|
||||||
, compile_ports
|
|
||||||
, erl_libs
|
, erl_libs
|
||||||
, plugins
|
|
||||||
, root
|
, root
|
||||||
, name}).
|
, name}).
|
||||||
|
|
||||||
@ -42,7 +40,6 @@ main(Args) ->
|
|||||||
-spec do_the_bootstrap(#data{}) -> ok.
|
-spec do_the_bootstrap(#data{}) -> ok.
|
||||||
do_the_bootstrap(RequiredData) ->
|
do_the_bootstrap(RequiredData) ->
|
||||||
ok = bootstrap_configs(RequiredData),
|
ok = bootstrap_configs(RequiredData),
|
||||||
ok = bootstrap_plugins(RequiredData),
|
|
||||||
ok = bootstrap_libs(RequiredData).
|
ok = bootstrap_libs(RequiredData).
|
||||||
|
|
||||||
%% @doc
|
%% @doc
|
||||||
@ -68,22 +65,8 @@ parse_args(Args0) ->
|
|||||||
bootstrap_configs(RequiredData)->
|
bootstrap_configs(RequiredData)->
|
||||||
io:format("Boostrapping app and rebar configurations~n"),
|
io:format("Boostrapping app and rebar configurations~n"),
|
||||||
ok = if_single_app_project_update_app_src_version(RequiredData),
|
ok = if_single_app_project_update_app_src_version(RequiredData),
|
||||||
ok = if_compile_ports_add_pc_plugin(RequiredData),
|
|
||||||
ok = if_debug_info_add(RequiredData).
|
ok = if_debug_info_add(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.
|
-spec bootstrap_libs(#data{}) -> ok.
|
||||||
bootstrap_libs(#data{erl_libs = ErlLibs}) ->
|
bootstrap_libs(#data{erl_libs = ErlLibs}) ->
|
||||||
io:format("Bootstrapping dependent libraries~n"),
|
io:format("Bootstrapping dependent libraries~n"),
|
||||||
@ -152,10 +135,9 @@ fixup_app_name(FileName) ->
|
|||||||
gather_required_data_from_the_environment(ArgData) ->
|
gather_required_data_from_the_environment(ArgData) ->
|
||||||
{ok, ArgData#data{ version = guard_env("version")
|
{ok, ArgData#data{ version = guard_env("version")
|
||||||
, erl_libs = get_env("ERL_LIBS", [])
|
, erl_libs = get_env("ERL_LIBS", [])
|
||||||
, plugins = get_env("buildPlugins", [])
|
|
||||||
, root = code:root_dir()
|
, root = code:root_dir()
|
||||||
, name = guard_env("name")
|
, name = guard_env("name")
|
||||||
, compile_ports = nix2bool(get_env("compilePorts", ""))}}.
|
}}.
|
||||||
|
|
||||||
-spec nix2bool(any()) -> boolean().
|
-spec nix2bool(any()) -> boolean().
|
||||||
nix2bool("1") ->
|
nix2bool("1") ->
|
||||||
@ -209,27 +191,6 @@ add_debug_info(Config) ->
|
|||||||
{erl_opts, [debug_info | ExistingOpts]})
|
{erl_opts, [debug_info | ExistingOpts]})
|
||||||
end.
|
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
|
|
||||||
{value, {plugins, ExistingPluginList}} -> ExistingPluginList;
|
|
||||||
_ -> []
|
|
||||||
end,
|
|
||||||
lists:keystore(plugins, 1, Config, {plugins, [pc | PluginList]}).
|
|
||||||
|
|
||||||
-spec read_rebar_config() -> [term()].
|
-spec read_rebar_config() -> [term()].
|
||||||
read_rebar_config() ->
|
read_rebar_config() ->
|
||||||
case file:consult("rebar.config") of
|
case file:consult("rebar.config") of
|
||||||
|
Loading…
Reference in New Issue
Block a user