20 , configurePhase ? null
26 shell = drv: stdenv.mkDerivation {
27 name = "interactive-shell-${drv.pname}";
28 buildInputs = [ drv ];
31 customPhases = lib.filterAttrs
33 { inherit setupHook configurePhase buildPhase installPhase; };
35 # When using the `beamDeps` argument, it is important that we use
36 # `rebar3WithPlugins` here even when there are no plugins. The vanilla
37 # `rebar3` package is an escript archive with bundled dependencies which can
38 # interfere with those in the app we are trying to build. `rebar3WithPlugins`
39 # doesn't have this issue since it puts its own deps last on the code path.
40 rebar3 = rebar3WithPlugins {
41 plugins = buildPlugins;
45 assert beamDeps != [ ] -> checkouts == null;
46 self: stdenv.mkDerivation (attrs // {
48 name = "${pname}-${version}";
49 inherit version pname;
51 buildInputs = buildInputs ++ [ erlang rebar3 openssl ] ++ beamDeps;
53 # ensure we strip any native binaries (eg. NIFs, ports)
54 stripDebugList = lib.optional (releaseType == "release") "rel";
58 REBAR_IGNORE_DEPS = beamDeps != [ ];
62 ${lib.optionalString (checkouts != null)
63 "cp --no-preserve=all -R ${checkouts}/_checkouts ."}
69 HOME=. DEBUG=1 rebar3 as ${profile} ${if releaseType == "escript"
77 dir=${if releaseType == "escript"
80 mkdir -p "$out/$dir" "$out/bin"
81 cp -R --preserve=mode "_build/${profile}/$dir" "$out"
82 ${lib.optionalString (releaseType == "release")
83 "find $out/rel/*/bin -type f -executable -exec ln -s -t $out/bin {} \\;"}
87 # Release will generate a binary which will cause a read null byte failure, see #261354
88 postInstall = lib.optionalString (releaseType == "escript") ''
89 for dir in $out/rel/*/erts-*; do
90 echo "ERTS found in $dir - removing references to erlang to reduce closure size"
91 for f in $dir/bin/{erl,start}; do
92 substituteInPlace "$f" --replace "${erlang}/lib/erlang" "''${dir/\/erts-*/}"
98 inherit (erlang.meta) platforms;
104 } // (if attrs ? passthru then attrs.passthru else { }));