rebar3WithPlugins: add ability to ignore dependencies

authored by David and committed by Raphael Megzari ae2f75ef 1ecc68dc

+48 -11
+2 -10
pkgs/development/beam-modules/rebar3-release.nix
··· 51 51 52 52 inherit src; 53 53 54 + REBAR_IGNORE_DEPS = beamDeps != [ ]; 55 + 54 56 configurePhase = '' 55 57 runHook preConfigure 56 58 ${lib.optionalString (checkouts != null) 57 59 "cp --no-preserve=all -R ${checkouts}/_checkouts ."} 58 - ${# Prevent rebar3 from trying to manage deps 59 - lib.optionalString (beamDeps != [ ]) '' 60 - erl -noshell -eval ' 61 - {ok, Terms0} = file:consult("rebar.config"), 62 - Terms = lists:keydelete(deps, 1, Terms0), 63 - ok = file:write_file("rebar.config", [io_lib:format("~tp.~n", [T]) || T <- Terms]), 64 - init:stop(0) 65 - ' 66 - rm -f rebar.lock 67 - ''} 68 60 runHook postConfigure 69 61 ''; 70 62
+3 -1
pkgs/development/tools/build-managers/rebar3/default.nix
··· 118 118 {ok, _} = zip:extract(Archive, [{cwd, "'$out/lib'"}]), 119 119 init:stop(0) 120 120 ' 121 + cp ${./rebar_ignore_deps.erl} rebar_ignore_deps.erl 122 + erlc -o $out/lib/rebar/ebin rebar_ignore_deps.erl 121 123 mkdir -p $out/bin 122 124 makeWrapper ${erlang}/bin/erl $out/bin/rebar3 \ 123 - --set REBAR_GLOBAL_PLUGINS "${toString globalPluginNames}" \ 125 + --set REBAR_GLOBAL_PLUGINS "${toString globalPluginNames} rebar_ignore_deps" \ 124 126 --suffix-each ERL_LIBS ":" "$out/lib ${toString pluginLibDirs}" \ 125 127 --add-flags "+sbtu +A1 -noshell -boot start_clean -s rebar3 main -extra" 126 128 '';
+43
pkgs/development/tools/build-managers/rebar3/rebar_ignore_deps.erl
··· 1 + %% This module, when loaded as a plugin, overrides the default `install_deps` 2 + %% provider and erases the dependencies from the rebar3 state, when 3 + %% REBAR_IGNORE_DEPS is true. 4 + 5 + -module(rebar_ignore_deps). 6 + 7 + -export([init/1, do/1, format_error/1]). 8 + 9 + init(State0) -> 10 + case os:getenv("REBAR_IGNORE_DEPS", "") of 11 + "" -> 12 + {ok, State0}; 13 + _ -> 14 + do_init(State0) 15 + end. 16 + 17 + do_init(State0) -> 18 + State1 = rebar_state:allow_provider_overrides(State0, true), 19 + Provider = providers:create( 20 + [ 21 + {name, install_deps}, %% override the default install_deps provider 22 + {module, ?MODULE}, 23 + {bare, false}, 24 + {deps, [app_discovery]}, 25 + {example, undefined}, 26 + {opts, []}, 27 + {short_desc, ""}, 28 + {desc, ""} 29 + ]), 30 + State2 = rebar_state:add_provider(State1, Provider), 31 + {ok, rebar_state:allow_provider_overrides(State2, false)}. 32 + 33 + do(State0) -> 34 + io:format("Ignoring deps...~n"), 35 + Profiles = rebar_state:current_profiles(State0), 36 + State = lists:foldl(fun(P, Acc0) -> 37 + Acc = rebar_state:set(Acc0, {deps, P}, []), 38 + rebar_state:set(Acc, {parsed_deps, P}, []) 39 + end, State0, Profiles), 40 + {ok, State}. 41 + 42 + format_error(Reason) -> 43 + io_lib:format("~p", [Reason]).