mixRelease: add flag for stripping debug from BEAM files
This commit is contained in:
parent
684a9bc32a
commit
9afb944758
@ -18,6 +18,7 @@
|
|||||||
, mixNixDeps ? { }
|
, mixNixDeps ? { }
|
||||||
, elixir ? inputs.elixir
|
, elixir ? inputs.elixir
|
||||||
, hex ? inputs.hex.override { inherit elixir; }
|
, hex ? inputs.hex.override { inherit elixir; }
|
||||||
|
, stripDebug ? true
|
||||||
, ...
|
, ...
|
||||||
}@attrs:
|
}@attrs:
|
||||||
let
|
let
|
||||||
@ -25,6 +26,8 @@ let
|
|||||||
overridable = builtins.removeAttrs attrs [ "compileFlags" "mixNixDeps" ];
|
overridable = builtins.removeAttrs attrs [ "compileFlags" "mixNixDeps" ];
|
||||||
in
|
in
|
||||||
assert mixNixDeps != { } -> mixFodDeps == null;
|
assert mixNixDeps != { } -> mixFodDeps == null;
|
||||||
|
assert stripDebug -> !enableDebugInfo;
|
||||||
|
|
||||||
stdenv.mkDerivation (overridable // {
|
stdenv.mkDerivation (overridable // {
|
||||||
# rg is used as a better grep to search for erlang references in the final release
|
# rg is used as a better grep to search for erlang references in the final release
|
||||||
nativeBuildInputs = nativeBuildInputs ++ [ erlang hex elixir makeWrapper git ripgrep ];
|
nativeBuildInputs = nativeBuildInputs ++ [ erlang hex elixir makeWrapper git ripgrep ];
|
||||||
@ -116,6 +119,10 @@ stdenv.mkDerivation (overridable // {
|
|||||||
substituteInPlace "$file" --replace "${erlang}/lib/erlang" "$out"
|
substituteInPlace "$file" --replace "${erlang}/lib/erlang" "$out"
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
'' + lib.optionalString stripDebug ''
|
||||||
|
# strip debug symbols to avoid hardreferences to "foreign" closures actually
|
||||||
|
# not needed at runtime, while at the same time reduce size of BEAM files.
|
||||||
|
erl -noinput -eval 'lists:foreach(fun(F) -> io:format("Stripping ~p.~n", [F]), beam_lib:strip(F) end, filelib:wildcard("'"$out"'/**/*.beam"))' -s init stop
|
||||||
'';
|
'';
|
||||||
|
|
||||||
# TODO investigate why the resulting closure still has
|
# TODO investigate why the resulting closure still has
|
||||||
|
Loading…
Reference in New Issue
Block a user