Merge pull request #16122 from ericbmerritt/feature/beam-package-improvements
Feature/beam package improvements
This commit is contained in:
commit
605c08d223
@ -1,4 +1,4 @@
|
|||||||
{ stdenv, writeText, erlang, perl, which, gitMinimal, wget }:
|
{ stdenv, writeText, erlang, perl, which, gitMinimal, wget, lib }:
|
||||||
|
|
||||||
{ name, version
|
{ name, version
|
||||||
, src
|
, src
|
||||||
@ -8,12 +8,17 @@
|
|||||||
, postPatch ? ""
|
, postPatch ? ""
|
||||||
, compilePorts ? false
|
, compilePorts ? false
|
||||||
, installPhase ? null
|
, installPhase ? null
|
||||||
|
, buildPhase ? null
|
||||||
|
, configurePhase ? null
|
||||||
, meta ? {}
|
, meta ? {}
|
||||||
|
, enableDebugInfo ? false
|
||||||
, ... }@attrs:
|
, ... }@attrs:
|
||||||
|
|
||||||
with stdenv.lib;
|
with stdenv.lib;
|
||||||
|
|
||||||
let
|
let
|
||||||
|
debugInfoFlag = lib.optionalString (enableDebugInfo || erlang.debugInfo) "+debug_info";
|
||||||
|
|
||||||
shell = drv: stdenv.mkDerivation {
|
shell = drv: stdenv.mkDerivation {
|
||||||
name = "interactive-shell-${drv.name}";
|
name = "interactive-shell-${drv.name}";
|
||||||
buildInputs = [ drv ];
|
buildInputs = [ drv ];
|
||||||
@ -37,7 +42,8 @@ let
|
|||||||
buildInputs = [ erlang perl which gitMinimal wget ];
|
buildInputs = [ erlang perl which gitMinimal wget ];
|
||||||
propagatedBuildInputs = beamDeps;
|
propagatedBuildInputs = beamDeps;
|
||||||
|
|
||||||
configurePhase = ''
|
configurePhase = if configurePhase == null
|
||||||
|
then ''
|
||||||
runHook preConfigure
|
runHook preConfigure
|
||||||
|
|
||||||
# We shouldnt need to do this, but it seems at times there is a *.app in
|
# We shouldnt need to do this, but it seems at times there is a *.app in
|
||||||
@ -45,17 +51,21 @@ let
|
|||||||
make SKIP_DEPS=1 clean
|
make SKIP_DEPS=1 clean
|
||||||
|
|
||||||
runHook postConfigure
|
runHook postConfigure
|
||||||
'';
|
''
|
||||||
|
else configurePhase;
|
||||||
|
|
||||||
buildPhase = ''
|
buildPhase = if buildPhase == null
|
||||||
|
then ''
|
||||||
runHook preBuild
|
runHook preBuild
|
||||||
|
|
||||||
make SKIP_DEPS=1
|
make SKIP_DEPS=1 ERL_OPTS="$ERL_OPTS ${debugInfoFlag}"
|
||||||
|
|
||||||
runHook postBuild
|
runHook postBuild
|
||||||
'';
|
''
|
||||||
|
else buildPhase;
|
||||||
|
|
||||||
installPhase = ''
|
installPhase = if installPhase == null
|
||||||
|
then ''
|
||||||
runHook preInstall
|
runHook preInstall
|
||||||
|
|
||||||
mkdir -p $out/lib/erlang/lib/${name}
|
mkdir -p $out/lib/erlang/lib/${name}
|
||||||
@ -75,7 +85,8 @@ let
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
runHook postInstall
|
runHook postInstall
|
||||||
'';
|
''
|
||||||
|
else installPhase;
|
||||||
|
|
||||||
passthru = {
|
passthru = {
|
||||||
packageName = name;
|
packageName = name;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{ stdenv, writeText, elixir, erlang, hexRegistrySnapshot, hex }:
|
{ stdenv, writeText, elixir, erlang, hexRegistrySnapshot, hex, lib }:
|
||||||
|
|
||||||
{ name
|
{ name
|
||||||
, version
|
, version
|
||||||
@ -8,12 +8,19 @@
|
|||||||
, beamDeps ? []
|
, beamDeps ? []
|
||||||
, postPatch ? ""
|
, postPatch ? ""
|
||||||
, compilePorts ? false
|
, compilePorts ? false
|
||||||
|
, installPhase ? null
|
||||||
|
, buildPhase ? null
|
||||||
|
, configurePhase ? null
|
||||||
, meta ? {}
|
, meta ? {}
|
||||||
|
, enableDebugInfo ? false
|
||||||
, ... }@attrs:
|
, ... }@attrs:
|
||||||
|
|
||||||
with stdenv.lib;
|
with stdenv.lib;
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
|
debugInfoFlag = lib.optionalString (enableDebugInfo || elixir.debugInfo) "--debug-info";
|
||||||
|
|
||||||
shell = drv: stdenv.mkDerivation {
|
shell = drv: stdenv.mkDerivation {
|
||||||
name = "interactive-shell-${drv.name}";
|
name = "interactive-shell-${drv.name}";
|
||||||
buildInputs = [ drv ];
|
buildInputs = [ drv ];
|
||||||
@ -38,25 +45,31 @@ let
|
|||||||
inherit buildInputs;
|
inherit buildInputs;
|
||||||
propagatedBuildInputs = [ hexRegistrySnapshot hex elixir ] ++ beamDeps;
|
propagatedBuildInputs = [ hexRegistrySnapshot hex elixir ] ++ beamDeps;
|
||||||
|
|
||||||
configurePhase = ''
|
configurePhase = if configurePhase == null
|
||||||
|
then ''
|
||||||
runHook preConfigure
|
runHook preConfigure
|
||||||
${erlang}/bin/escript ${bootstrapper}
|
${erlang}/bin/escript ${bootstrapper}
|
||||||
runHook postConfigure
|
runHook postConfigure
|
||||||
'';
|
''
|
||||||
|
else configurePhase ;
|
||||||
|
|
||||||
buildPhase = ''
|
|
||||||
|
buildPhase = if buildPhase == null
|
||||||
|
then ''
|
||||||
runHook preBuild
|
runHook preBuild
|
||||||
|
|
||||||
export HEX_OFFLINE=1
|
export HEX_OFFLINE=1
|
||||||
export HEX_HOME=`pwd`
|
export HEX_HOME=`pwd`
|
||||||
export MIX_ENV=prod
|
export MIX_ENV=prod
|
||||||
|
|
||||||
MIX_ENV=prod mix compile --debug-info --no-deps-check
|
MIX_ENV=prod mix compile ${debugInfoFlag} --no-deps-check
|
||||||
|
|
||||||
runHook postBuild
|
runHook postBuild
|
||||||
'';
|
''
|
||||||
|
else buildPhase;
|
||||||
|
|
||||||
installPhase = ''
|
installPhase = if installPhase == null
|
||||||
|
then ''
|
||||||
runHook preInstall
|
runHook preInstall
|
||||||
|
|
||||||
MIXENV=prod
|
MIXENV=prod
|
||||||
@ -74,7 +87,8 @@ let
|
|||||||
done
|
done
|
||||||
|
|
||||||
runHook postInstall
|
runHook postInstall
|
||||||
'';
|
''
|
||||||
|
else installPhase;
|
||||||
|
|
||||||
passthru = {
|
passthru = {
|
||||||
packageName = name;
|
packageName = name;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{ stdenv, writeText, erlang, rebar3, openssl, libyaml,
|
{ stdenv, writeText, erlang, rebar3, openssl, libyaml,
|
||||||
pc, buildEnv }:
|
pc, buildEnv, lib }:
|
||||||
|
|
||||||
{ name, version
|
{ name, version
|
||||||
, src
|
, src
|
||||||
@ -8,12 +8,17 @@
|
|||||||
, postPatch ? ""
|
, postPatch ? ""
|
||||||
, compilePorts ? false
|
, compilePorts ? false
|
||||||
, installPhase ? null
|
, installPhase ? null
|
||||||
|
, buildPhase ? null
|
||||||
|
, configurePhase ? null
|
||||||
, meta ? {}
|
, meta ? {}
|
||||||
|
, enableDebugInfo ? false
|
||||||
, ... }@attrs:
|
, ... }@attrs:
|
||||||
|
|
||||||
with stdenv.lib;
|
with stdenv.lib;
|
||||||
|
|
||||||
let
|
let
|
||||||
|
debugInfoFlag = lib.optionalString (enableDebugInfo || erlang.debugInfo) "debug-info";
|
||||||
|
|
||||||
ownPlugins = buildPlugins ++ (if compilePorts then [pc] else []);
|
ownPlugins = buildPlugins ++ (if compilePorts then [pc] else []);
|
||||||
|
|
||||||
shell = drv: stdenv.mkDerivation {
|
shell = drv: stdenv.mkDerivation {
|
||||||
@ -46,20 +51,24 @@ let
|
|||||||
rm -f rebar rebar3
|
rm -f rebar rebar3
|
||||||
'';
|
'';
|
||||||
|
|
||||||
configurePhase = ''
|
configurePhase = if configurePhase == null
|
||||||
|
then ''
|
||||||
runHook preConfigure
|
runHook preConfigure
|
||||||
${erlang}/bin/escript ${rebar3.bootstrapper}
|
${erlang}/bin/escript ${rebar3.bootstrapper} ${debugInfoFlag}
|
||||||
runHook postConfigure
|
runHook postConfigure
|
||||||
'';
|
''
|
||||||
|
else configurePhase;
|
||||||
|
|
||||||
buildPhase = ''
|
buildPhase = if buildPhase == null
|
||||||
|
then ''
|
||||||
runHook preBuild
|
runHook preBuild
|
||||||
HOME=. rebar3 compile
|
HOME=. rebar3 compile
|
||||||
${if compilePorts then ''
|
${if compilePorts then ''
|
||||||
HOME=. rebar3 pc compile
|
HOME=. rebar3 pc compile
|
||||||
'' else ''''}
|
'' else ''''}
|
||||||
runHook postBuild
|
runHook postBuild
|
||||||
'';
|
''
|
||||||
|
else installPhase;
|
||||||
|
|
||||||
installPhase = if installPhase == null
|
installPhase = if installPhase == null
|
||||||
then ''
|
then ''
|
||||||
|
@ -10,7 +10,7 @@ stdenv.mkDerivation ({
|
|||||||
name = "hex-source-${pkg}-${version}";
|
name = "hex-source-${pkg}-${version}";
|
||||||
|
|
||||||
src = fetchurl {
|
src = fetchurl {
|
||||||
url = "https://s3.amazonaws.com/s3.hex.pm/tarballs/${pkg}-${version}.tar";
|
url = "https://repo.hex.pm/tarballs/${pkg}-${version}.tar";
|
||||||
inherit sha256;
|
inherit sha256;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -2,14 +2,14 @@
|
|||||||
|
|
||||||
stdenv.mkDerivation rec {
|
stdenv.mkDerivation rec {
|
||||||
name = "hex-registry";
|
name = "hex-registry";
|
||||||
rev = "59b836d";
|
rev = "d58a937";
|
||||||
version = "0.0.0+build.${rev}";
|
version = "0.0.0+build.${rev}";
|
||||||
|
|
||||||
src = fetchFromGitHub {
|
src = fetchFromGitHub {
|
||||||
owner = "erlang-nix";
|
owner = "erlang-nix";
|
||||||
repo = "hex-pm-registry-snapshots";
|
repo = "hex-pm-registry-snapshots";
|
||||||
inherit rev;
|
inherit rev;
|
||||||
sha256 = "1l8m6ckn5ivhfiv3k4dymi6b7wg511fwymnpxd6ymfd39dq0n5b0";
|
sha256 = "11ymmn75qjlhzf7aaza708gq0hqg55dzd3q13npgq43wg90rgpxy";
|
||||||
};
|
};
|
||||||
|
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
|
@ -21,6 +21,8 @@ stdenv.mkDerivation rec {
|
|||||||
|
|
||||||
setupHook = ./setup-hook.sh;
|
setupHook = ./setup-hook.sh;
|
||||||
|
|
||||||
|
inherit debugInfo;
|
||||||
|
|
||||||
buildFlags = if debugInfo
|
buildFlags = if debugInfo
|
||||||
then "ERL_COMPILER_OPTIONS=debug_info"
|
then "ERL_COMPILER_OPTIONS=debug_info"
|
||||||
else "";
|
else "";
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
{ stdenv, fetchurl, perl, gnum4, ncurses, openssl
|
{ stdenv, fetchurl, perl, gnum4, ncurses, openssl
|
||||||
, gnused, gawk, makeWrapper
|
, gnused, gawk, makeWrapper
|
||||||
, odbcSupport ? false, unixODBC ? null
|
, odbcSupport ? false, unixODBC ? null
|
||||||
, wxSupport ? false, mesa ? null, wxGTK ? null, xorg ? null }:
|
, wxSupport ? false, mesa ? null, wxGTK ? null, xorg ? null
|
||||||
|
, enableDebugInfo ? false }:
|
||||||
|
|
||||||
assert wxSupport -> mesa != null && wxGTK != null && xorg != null;
|
assert wxSupport -> mesa != null && wxGTK != null && xorg != null;
|
||||||
assert odbcSupport -> unixODBC != null;
|
assert odbcSupport -> unixODBC != null;
|
||||||
@ -17,6 +18,8 @@ stdenv.mkDerivation rec {
|
|||||||
sha256 = "1rvyfh22g1fir1i4xn7v2md868wcmhajwhfsq97v7kn5kd2m7khp";
|
sha256 = "1rvyfh22g1fir1i4xn7v2md868wcmhajwhfsq97v7kn5kd2m7khp";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
debugInfo = enableDebugInfo;
|
||||||
|
|
||||||
buildInputs =
|
buildInputs =
|
||||||
[ perl gnum4 ncurses openssl makeWrapper
|
[ perl gnum4 ncurses openssl makeWrapper
|
||||||
] ++ optional wxSupport [ mesa wxGTK xorg.libX11 ]
|
] ++ optional wxSupport [ mesa wxGTK xorg.libX11 ]
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
, wxSupport ? true, mesa ? null, wxGTK ? null, xorg ? null, wxmac ? null
|
, wxSupport ? true, mesa ? null, wxGTK ? null, xorg ? null, wxmac ? null
|
||||||
, javacSupport ? false, openjdk ? null
|
, javacSupport ? false, openjdk ? null
|
||||||
, enableHipe ? true
|
, enableHipe ? true
|
||||||
|
, enableDebugInfo ? false
|
||||||
}:
|
}:
|
||||||
|
|
||||||
assert wxSupport -> (if stdenv.isDarwin
|
assert wxSupport -> (if stdenv.isDarwin
|
||||||
@ -35,6 +36,8 @@ stdenv.mkDerivation rec {
|
|||||||
|
|
||||||
patchPhase = '' sed -i "s@/bin/rm@rm@" lib/odbc/configure erts/configure '';
|
patchPhase = '' sed -i "s@/bin/rm@rm@" lib/odbc/configure erts/configure '';
|
||||||
|
|
||||||
|
debugInfo = enableDebugInfo;
|
||||||
|
|
||||||
preConfigure = ''
|
preConfigure = ''
|
||||||
export HOME=$PWD/../
|
export HOME=$PWD/../
|
||||||
sed -e s@/bin/pwd@pwd@g -i otp_build
|
sed -e s@/bin/pwd@pwd@g -i otp_build
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
, wxSupport ? true, mesa ? null, wxGTK ? null, xorg ? null, wxmac ? null
|
, wxSupport ? true, mesa ? null, wxGTK ? null, xorg ? null, wxmac ? null
|
||||||
, javacSupport ? false, openjdk ? null
|
, javacSupport ? false, openjdk ? null
|
||||||
, enableHipe ? true
|
, enableHipe ? true
|
||||||
|
, enableDebugInfo ? false
|
||||||
}:
|
}:
|
||||||
|
|
||||||
assert wxSupport -> (if stdenv.isDarwin
|
assert wxSupport -> (if stdenv.isDarwin
|
||||||
@ -33,6 +34,8 @@ stdenv.mkDerivation rec {
|
|||||||
++ optional javacSupport openjdk
|
++ optional javacSupport openjdk
|
||||||
++ stdenv.lib.optionals stdenv.isDarwin [ Carbon Cocoa ];
|
++ stdenv.lib.optionals stdenv.isDarwin [ Carbon Cocoa ];
|
||||||
|
|
||||||
|
debugInfo = enableDebugInfo;
|
||||||
|
|
||||||
patchPhase = '' sed -i "s@/bin/rm@rm@" lib/odbc/configure erts/configure '';
|
patchPhase = '' sed -i "s@/bin/rm@rm@" lib/odbc/configure erts/configure '';
|
||||||
|
|
||||||
preConfigure = ''
|
preConfigure = ''
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
-record(data, {version
|
-record(data, {version
|
||||||
, registry_only = false
|
, registry_only = false
|
||||||
|
, debug_info = false
|
||||||
, compile_ports
|
, compile_ports
|
||||||
, erl_libs
|
, erl_libs
|
||||||
, plugins
|
, plugins
|
||||||
@ -54,21 +55,29 @@ do_the_bootstrap(RequiredData) ->
|
|||||||
%% @doc
|
%% @doc
|
||||||
%% Argument parsing is super simple only because we want to keep the
|
%% Argument parsing is super simple only because we want to keep the
|
||||||
%% dependencies minimal. For now there can be two entries on the
|
%% dependencies minimal. For now there can be two entries on the
|
||||||
%% command line, "registery-only"
|
%% command line, "registery-only" and "debug-info"
|
||||||
-spec parse_args([string()]) -> #data{}.
|
-spec parse_args([string()]) -> #data{}.
|
||||||
parse_args(["registry-only"]) ->
|
parse_args(Args0) ->
|
||||||
{ok, #data{registry_only = true}};
|
PossibleArgs = sets:from_list(["registry-only", "debug-info"]),
|
||||||
parse_args([]) ->
|
Args1 = sets:from_list(Args0),
|
||||||
{ok, #data{registry_only = false}};
|
Result = sets:subtract(Args1, PossibleArgs),
|
||||||
parse_args(Args) ->
|
case sets:to_list(Result) of
|
||||||
io:format("Unexpected command line arguments passed in: ~p~n", [Args]),
|
[] ->
|
||||||
erlang:halt(120).
|
{ok, #data{registry_only = sets:is_element("registry-only", Args1),
|
||||||
|
debug_info = sets:is_element("debug-info", Args1)}};
|
||||||
|
UnknownArgs ->
|
||||||
|
io:format("Unexpected command line arguments passed in: ~p~n",
|
||||||
|
[UnknownArgs]),
|
||||||
|
erlang:halt(120)
|
||||||
|
end.
|
||||||
|
|
||||||
|
|
||||||
-spec bootstrap_configs(#data{}) -> ok.
|
-spec bootstrap_configs(#data{}) -> ok.
|
||||||
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_compile_ports_add_pc_plugin(RequiredData),
|
||||||
|
ok = if_debug_info_add(RequiredData).
|
||||||
|
|
||||||
-spec bootstrap_plugins(#data{}) -> ok.
|
-spec bootstrap_plugins(#data{}) -> ok.
|
||||||
bootstrap_plugins(#data{plugins = Plugins}) ->
|
bootstrap_plugins(#data{plugins = Plugins}) ->
|
||||||
@ -198,6 +207,33 @@ guard_env(Name) ->
|
|||||||
Variable
|
Variable
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
%% @doc
|
||||||
|
%% If debug info is set we need to add debug info to the list of compile options
|
||||||
|
%%
|
||||||
|
-spec if_debug_info_add(#data{}) -> ok.
|
||||||
|
if_debug_info_add(#data{debug_info = true}) ->
|
||||||
|
ConfigTerms = add_debug_info(read_rebar_config()),
|
||||||
|
Text = lists:map(fun(Term) -> io_lib:format("~tp.~n", [Term]) end,
|
||||||
|
ConfigTerms),
|
||||||
|
file:write_file("rebar.config", Text);
|
||||||
|
if_debug_info_add(_) ->
|
||||||
|
ok.
|
||||||
|
|
||||||
|
-spec add_debug_info([term()]) -> [term()].
|
||||||
|
add_debug_info(Config) ->
|
||||||
|
ExistingOpts = case lists:keysearch(erl_opts, 1, Config) of
|
||||||
|
{value, {erl_opts, ExistingOptsList}} -> ExistingOptsList;
|
||||||
|
_ -> []
|
||||||
|
end,
|
||||||
|
case lists:member(debug_info, ExistingOpts) of
|
||||||
|
true ->
|
||||||
|
Config;
|
||||||
|
false ->
|
||||||
|
lists:keystore(erl_opts, 1, Config,
|
||||||
|
{erl_opts, [debug_info | ExistingOpts]})
|
||||||
|
end.
|
||||||
|
|
||||||
|
|
||||||
%% @doc
|
%% @doc
|
||||||
%% If the compile ports flag is set, rewrite the rebar config to
|
%% If the compile ports flag is set, rewrite the rebar config to
|
||||||
%% include the 'pc' plugin.
|
%% include the 'pc' plugin.
|
||||||
@ -213,7 +249,7 @@ if_compile_ports_add_pc_plugin(_) ->
|
|||||||
-spec add_pc_to_plugins([term()]) -> [term()].
|
-spec add_pc_to_plugins([term()]) -> [term()].
|
||||||
add_pc_to_plugins(Config) ->
|
add_pc_to_plugins(Config) ->
|
||||||
PluginList = case lists:keysearch(plugins, 1, Config) of
|
PluginList = case lists:keysearch(plugins, 1, Config) of
|
||||||
{ok, {plugins, ExistingPluginList}} -> ExistingPluginList;
|
{value, {plugins, ExistingPluginList}} -> ExistingPluginList;
|
||||||
_ -> []
|
_ -> []
|
||||||
end,
|
end,
|
||||||
lists:keystore(plugins, 1, Config, {plugins, [pc | PluginList]}).
|
lists:keystore(plugins, 1, Config, {plugins, [pc | PluginList]}).
|
||||||
|
@ -1,23 +0,0 @@
|
|||||||
{stdenv, writeText, fetchFromGitHub }:
|
|
||||||
|
|
||||||
stdenv.mkDerivation rec {
|
|
||||||
name = "hex-registry";
|
|
||||||
rev = "329ae2b";
|
|
||||||
version = "0.0.0+build.${rev}";
|
|
||||||
|
|
||||||
src = fetchFromGitHub {
|
|
||||||
owner = "erlang-nix";
|
|
||||||
repo = "hex-pm-registry-snapshots";
|
|
||||||
inherit rev;
|
|
||||||
sha256 = "1rs3z8psfvy10mzlfvkdzbflgikcnq08r38kfi0f8p5wvi8f8hmh";
|
|
||||||
};
|
|
||||||
|
|
||||||
installPhase = ''
|
|
||||||
mkdir -p "$out/var/hex"
|
|
||||||
zcat "registry.ets.gz" > "$out/var/hex/registry.ets"
|
|
||||||
'';
|
|
||||||
|
|
||||||
setupHook = writeText "setupHook.sh" ''
|
|
||||||
export HEX_REGISTRY_SNAPSHOT="$1/var/hex/registry.ets"
|
|
||||||
'';
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user