Add support for rebar3 plugins to buildHex.

Allow specifying pluginDeps for buildHex listing rebar3 plugins which
are required for given package to be built by rebar3.
This commit is contained in:
Gleb Peregud 2015-12-10 23:11:25 +01:00
parent eac25eaf69
commit 3a9110b15c
4 changed files with 22 additions and 3 deletions

View File

@ -2,7 +2,7 @@
{ name, version, sha256 { name, version, sha256
, hexPkg ? name , hexPkg ? name
, buildInputs ? [], erlangDeps ? [] , buildInputs ? [], erlangDeps ? [], pluginDeps ? []
, postPatch ? "" , postPatch ? ""
, compilePorts ? false , compilePorts ? false
, ... }@attrs: , ... }@attrs:
@ -39,14 +39,22 @@ stdenv.mkDerivation (attrs // {
recursiveDeps = uniqList { recursiveDeps = uniqList {
inputList = flatten (map getDeps erlangDeps); inputList = flatten (map getDeps erlangDeps);
}; };
recursivePluginsDeps = uniqList {
inputList = flatten (map getDeps pluginDeps);
};
in '' in ''
runHook preConfigure runHook preConfigure
mkdir -p _build/default/lib/ mkdir -p _build/default/{lib,plugins}/
${concatMapStrings (dep: '' ${concatMapStrings (dep: ''
header "linking erlang dependency ${dep}" header "linking erlang dependency ${dep}"
ln -s "${dep}" "_build/default/lib/${dep.packageName}" ln -s "${dep}" "_build/default/lib/${dep.packageName}"
stopNest stopNest
'') recursiveDeps} '') recursiveDeps}
${concatMapStrings (dep: ''
header "linking rebar3 plugins ${dep}"
ln -s "${dep}" "_build/default/plugins/${dep.packageName}"
stopNest
'') recursivePluginsDeps}
runHook postConfigure runHook postConfigure
''; '';
@ -55,7 +63,9 @@ stdenv.mkDerivation (attrs // {
buildPhase = '' buildPhase = ''
runHook preBuild runHook preBuild
HOME=. rebar3 do update, compile HOME=. rebar3 do update, compile
${if compilePorts then ''
HOME=. rebar3 pc compile HOME=. rebar3 pc compile
'' else ''''}
runHook postBuild runHook postBuild
''; '';

View File

@ -7,6 +7,7 @@ let
buildErlang = callPackage ./build-erlang.nix {}; buildErlang = callPackage ./build-erlang.nix {};
buildHex = callPackage ./build-hex.nix {}; buildHex = callPackage ./build-hex.nix {};
rebar3-pc = callPackage ./hex/rebar3-pc.nix {};
esqlite = callPackage ./hex/esqlite.nix {}; esqlite = callPackage ./hex/esqlite.nix {};
goldrush = callPackage ./hex/goldrush.nix {}; goldrush = callPackage ./hex/goldrush.nix {};
ibrowse = callPackage ./hex/ibrowse.nix {}; ibrowse = callPackage ./hex/ibrowse.nix {};

View File

@ -1,8 +1,9 @@
{ buildHex }: { buildHex, rebar3-pc }:
buildHex { buildHex {
name = "esqlite"; name = "esqlite";
version = "0.2.1"; version = "0.2.1";
sha256 = "1296fn1lz4lz4zqzn4dwc3flgkh0i6n4sydg501faabfbv8d3wkr"; sha256 = "1296fn1lz4lz4zqzn4dwc3flgkh0i6n4sydg501faabfbv8d3wkr";
compilePorts = true; compilePorts = true;
pluginDeps = [ rebar3-pc ];
} }

View File

@ -0,0 +1,7 @@
{ buildHex, goldrush }:
buildHex {
name = "pc";
version = "1.1.0";
sha256 = "1br5xfl4b2z70b6a2ccxppn64jvkqgpmy4y9v81kxzb91z0ss9ma";
}