forked from mirrors/nixpkgs
Add shell env to buildHex packages.
This adds erlangPackages.${name}.env, which is usable to launch a shell with the package and it's dependencies like this: nix-shell -A erlangPackages.lager.env This required: 1) refactoring buildHex to become a fixed-point function, 2) moves output of a package into $out/${name}, 3) introduces erlEnv (buildEnv, which links in package and it's deps into one directory - a super-simple plagiarization of haskellPackages.compiler.ghcWithPackages) and 4) shell function producing a un-buildable derivation to be used by nix-shell
This commit is contained in:
parent
b3b7f9f37f
commit
d7e17c2e71
|
@ -1,3 +1,6 @@
|
||||||
|
# This file is not used not tested at this time, build-hex.nix is the currently
|
||||||
|
# main vehicle of bringing Erlang packages in.
|
||||||
|
|
||||||
{ stdenv, erlang, rebar, openssl, libyaml }:
|
{ stdenv, erlang, rebar, openssl, libyaml }:
|
||||||
|
|
||||||
{ name, version
|
{ name, version
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{ stdenv, erlang, rebar3, openssl, libyaml, fetchHex, fetchFromGitHub,
|
{ stdenv, erlang, rebar3, openssl, libyaml, fetchHex, fetchFromGitHub,
|
||||||
rebar3-pc }:
|
rebar3-pc, buildEnv }:
|
||||||
|
|
||||||
{ name, version, sha256
|
{ name, version, sha256
|
||||||
, hexPkg ? name
|
, hexPkg ? name
|
||||||
|
@ -11,7 +11,29 @@
|
||||||
|
|
||||||
with stdenv.lib;
|
with stdenv.lib;
|
||||||
|
|
||||||
stdenv.mkDerivation (attrs // {
|
let
|
||||||
|
plugins = pluginDeps ++ (if compilePorts then [rebar3-pc] else []);
|
||||||
|
getDeps = drv: [drv] ++ (map getDeps drv.erlangDeps);
|
||||||
|
recursiveDeps = unique (flatten (map getDeps erlangDeps));
|
||||||
|
recursivePluginsDeps = unique (flatten (map getDeps plugins));
|
||||||
|
|
||||||
|
erlEnv = drv: buildEnv {
|
||||||
|
name = "erlang-env-${drv.name}";
|
||||||
|
paths = [ drv ] ++ recursiveDeps;
|
||||||
|
ignoreCollisions = false;
|
||||||
|
meta = drv.meta;
|
||||||
|
};
|
||||||
|
|
||||||
|
shell = drv: let
|
||||||
|
drvEnv = erlEnv drv;
|
||||||
|
in stdenv.mkDerivation {
|
||||||
|
name = "interactive-shell-${drv.name}";
|
||||||
|
nativeBuildInputs = [ erlang drvEnv ];
|
||||||
|
shellHook = ''
|
||||||
|
export ERL_LIBS="${drvEnv}";
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
pkg = self: stdenv.mkDerivation (attrs // {
|
||||||
name = "${name}-${version}";
|
name = "${name}-${version}";
|
||||||
|
|
||||||
buildInputs = buildInputs ++ [ erlang rebar3 openssl libyaml ];
|
buildInputs = buildInputs ++ [ erlang rebar3 openssl libyaml ];
|
||||||
|
@ -37,21 +59,16 @@ stdenv.mkDerivation (attrs // {
|
||||||
${postPatch}
|
${postPatch}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
configurePhase = let
|
configurePhase = ''
|
||||||
plugins = pluginDeps ++ (if compilePorts then [rebar3-pc] else []);
|
|
||||||
getDeps = drv: [drv] ++ (map getDeps drv.erlangDeps);
|
|
||||||
recursiveDeps = unique (flatten (map getDeps erlangDeps));
|
|
||||||
recursivePluginsDeps = unique (flatten (map getDeps plugins));
|
|
||||||
in ''
|
|
||||||
runHook preConfigure
|
runHook preConfigure
|
||||||
${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}/${dep.name}" "_build/default/lib/${dep.name}"
|
||||||
stopNest
|
stopNest
|
||||||
'') recursiveDeps}
|
'') recursiveDeps}
|
||||||
${concatMapStrings (dep: ''
|
${concatMapStrings (dep: ''
|
||||||
header "linking rebar3 plugins ${dep}"
|
header "linking rebar3 plugins ${dep}"
|
||||||
ln -s "${dep}" "_build/default/plugins/${dep.packageName}"
|
ln -s "${dep}/${dep.name}" "_build/default/plugins/${dep.name}"
|
||||||
stopNest
|
stopNest
|
||||||
'') recursivePluginsDeps}
|
'') recursivePluginsDeps}
|
||||||
runHook postConfigure
|
runHook postConfigure
|
||||||
|
@ -68,11 +85,11 @@ stdenv.mkDerivation (attrs // {
|
||||||
|
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
runHook preInstall
|
runHook preInstall
|
||||||
mkdir "$out"
|
mkdir -p "$out/${name}"
|
||||||
for reldir in src ebin priv include; do
|
for reldir in src ebin priv include; do
|
||||||
fd="_build/default/lib/${name}/$reldir"
|
fd="_build/default/lib/${name}/$reldir"
|
||||||
[ -d "$fd" ] || continue
|
[ -d "$fd" ] || continue
|
||||||
cp -Hrt "$out" "$fd"
|
cp -Hrt "$out/${name}" "$fd"
|
||||||
success=1
|
success=1
|
||||||
done
|
done
|
||||||
runHook postInstall
|
runHook postInstall
|
||||||
|
@ -84,6 +101,9 @@ stdenv.mkDerivation (attrs // {
|
||||||
|
|
||||||
passthru = {
|
passthru = {
|
||||||
packageName = name;
|
packageName = name;
|
||||||
|
env = shell self;
|
||||||
inherit erlangDeps;
|
inherit erlangDeps;
|
||||||
};
|
};
|
||||||
})
|
});
|
||||||
|
in
|
||||||
|
fix pkg
|
||||||
|
|
Loading…
Reference in a new issue