diff options
Diffstat (limited to 'nixpkgs/pkgs/development/beam-modules/mix-release.nix')
-rw-r--r-- | nixpkgs/pkgs/development/beam-modules/mix-release.nix | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/beam-modules/mix-release.nix b/nixpkgs/pkgs/development/beam-modules/mix-release.nix index 0b7229a21b5a..1d40da27ecba 100644 --- a/nixpkgs/pkgs/development/beam-modules/mix-release.nix +++ b/nixpkgs/pkgs/development/beam-modules/mix-release.nix @@ -9,15 +9,25 @@ , enableDebugInfo ? false , mixEnv ? "prod" , compileFlags ? [ ] + # mix fixed output derivation dependencies , mixFodDeps ? null + # mix dependencies generated by mix2nix # this assumes each dependency is built by buildMix or buildRebar3 # each dependency needs to have a setup hook to add the lib path to $ERL_LIBS # this is how mix will find dependencies , mixNixDeps ? { } + , elixir ? inputs.elixir , hex ? inputs.hex.override { inherit elixir; } + +# This reduces closure size, but can lead to some hard to understand runtime +# errors, so use with caution. See e.g. +# https://github.com/whitfin/cachex/issues/205 +# https://framagit.org/framasoft/mobilizon/-/issues/1169 +, stripDebug ? false + , ... }@attrs: let @@ -25,6 +35,8 @@ let overridable = builtins.removeAttrs attrs [ "compileFlags" "mixNixDeps" ]; in assert mixNixDeps != { } -> mixFodDeps == null; +assert stripDebug -> !enableDebugInfo; + stdenv.mkDerivation (overridable // { # rg is used as a better grep to search for erlang references in the final release nativeBuildInputs = nativeBuildInputs ++ [ erlang hex elixir makeWrapper git ripgrep ]; @@ -116,6 +128,10 @@ stdenv.mkDerivation (overridable // { substituteInPlace "$file" --replace "${erlang}/lib/erlang" "$out" done 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 |