diff options
Diffstat (limited to 'pkgs/development/beam-modules/build-rebar3.nix')
-rw-r--r-- | pkgs/development/beam-modules/build-rebar3.nix | 62 |
1 files changed, 28 insertions, 34 deletions
diff --git a/pkgs/development/beam-modules/build-rebar3.nix b/pkgs/development/beam-modules/build-rebar3.nix index 224d111026a..0dfd68f0993 100644 --- a/pkgs/development/beam-modules/build-rebar3.nix +++ b/pkgs/development/beam-modules/build-rebar3.nix @@ -1,30 +1,34 @@ -{ stdenv, writeText, erlang, rebar3, openssl, libyaml, - pc, lib }: +{ stdenv, writeText, erlang, rebar3WithPlugins, openssl, libyaml, lib }: -{ name, version +{ name +, version , src , setupHook ? null -, buildInputs ? [], beamDeps ? [], buildPlugins ? [] +, buildInputs ? [ ] +, beamDeps ? [ ] +, buildPlugins ? [ ] , postPatch ? "" -, compilePorts ? false , installPhase ? null , buildPhase ? null , configurePhase ? null -, meta ? {} +, meta ? { } , enableDebugInfo ? false -, ... }@attrs: +, ... +}@attrs: -with stdenv.lib; +with lib; let debugInfoFlag = lib.optionalString (enableDebugInfo || erlang.debugInfo) "debug-info"; - ownPlugins = buildPlugins ++ (if compilePorts then [pc] else []); + rebar3 = rebar3WithPlugins { + plugins = buildPlugins; + }; shell = drv: stdenv.mkDerivation { - name = "interactive-shell-${drv.name}"; - buildInputs = [ drv ]; - }; + name = "interactive-shell-${drv.name}"; + buildInputs = [ drv ]; + }; customPhases = filterAttrs (_: v: v != null) @@ -36,35 +40,26 @@ let inherit version; buildInputs = buildInputs ++ [ erlang rebar3 openssl libyaml ]; - propagatedBuildInputs = unique (beamDeps ++ ownPlugins); - - dontStrip = true; - # The following are used by rebar3-nix-bootstrap - inherit compilePorts; - buildPlugins = ownPlugins; + propagatedBuildInputs = unique beamDeps; inherit src; + # stripping does not have any effect on beam files + # it is however needed for dependencies with NIFs + # false is the default but we keep this for readability + dontStrip = false; + setupHook = writeText "setupHook.sh" '' - addToSearchPath ERL_LIBS "$1/lib/erlang/lib/" + addToSearchPath ERL_LIBS "$1/lib/erlang/lib/" ''; postPatch = '' rm -f rebar rebar3 '' + postPatch; - configurePhase = '' - runHook preConfigure - ${erlang}/bin/escript ${rebar3.bootstrapper} ${debugInfoFlag} - runHook postConfigure - ''; - buildPhase = '' runHook preBuild - HOME=. rebar3 compile - ${if compilePorts then '' - HOME=. rebar3 pc compile - '' else ''''} + HOME=. rebar3 bare compile -path "" runHook postBuild ''; @@ -72,10 +67,9 @@ let runHook preInstall mkdir -p "$out/lib/erlang/lib/${name}-${version}" for reldir in src ebin priv include; do - fd="_build/default/lib/${name}/$reldir" - [ -d "$fd" ] || continue - cp -Hrt "$out/lib/erlang/lib/${name}-${version}" "$fd" - success=1 + [ -d "$reldir" ] || continue + # $out/lib/erlang/lib is a convention used in nixpkgs for compiled BEAM packages + cp -Hrt "$out/lib/erlang/lib/${name}-${version}" "$reldir" done runHook postInstall ''; @@ -91,4 +85,4 @@ let }; } // customPhases); in - fix pkg +fix pkg |