mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-12-26 04:43:09 +03:00
Merge pull request #12409 from erlang-nix/master
Improvements for Erlang support in Nix
This commit is contained in:
commit
7824b8c330
288
doc/erlang-users-guide.xml
Normal file
288
doc/erlang-users-guide.xml
Normal file
@ -0,0 +1,288 @@
|
||||
<chapter xmlns="http://docbook.org/ns/docbook"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xml:id="users-guide-to-the-erlang-infrastructure">
|
||||
|
||||
<title>User's Guide to the Erlang Infrastructure</title>
|
||||
|
||||
<section xml:id="how-to-install-erlang-packages">
|
||||
<title>How to install Erlang packages</title>
|
||||
<para>
|
||||
Erlang packages are not registered in the top level simply because
|
||||
they are not relevant to the vast majority of Nix users. They are
|
||||
installable using the <literal>erlangPackages</literal> attribute set.
|
||||
|
||||
You can list the avialable packages in the
|
||||
<literal>erlangPackages</literal> with the following command:
|
||||
</para>
|
||||
|
||||
<programlisting>
|
||||
$ nix-env -f "<nixpkgs>" -qaP -A erlangPackages
|
||||
erlangPackages.esqlite esqlite-0.2.1
|
||||
erlangPackages.goldrush goldrush-0.1.7
|
||||
erlangPackages.ibrowse ibrowse-4.2.2
|
||||
erlangPackages.jiffy jiffy-0.14.5
|
||||
erlangPackages.lager lager-3.0.2
|
||||
erlangPackages.meck meck-0.8.3
|
||||
erlangPackages.rebar3-pc pc-1.1.0
|
||||
</programlisting>
|
||||
<para>
|
||||
To install any of those packages into your profile, refer to them by
|
||||
their attribute path (first column):
|
||||
</para>
|
||||
<programlisting>
|
||||
$ nix-env -f "<nixpkgs>" -iA erlangPackages.ibrowse
|
||||
</programlisting>
|
||||
<para>
|
||||
The attribute path of any Erlang packages corresponds to the name
|
||||
of that particular package in Hex or its OTP Application/Release name.
|
||||
</para>
|
||||
</section>
|
||||
<section xml:id="packaging-erlang-applications">
|
||||
<title>Packaging Erlang Applications</title>
|
||||
<section xml:id="rebar3-packages">
|
||||
<title>Rebar3 Packages</title>
|
||||
<para>
|
||||
There is a Nix functional called
|
||||
<literal>buildRebar3</literal>. We use this function to make a
|
||||
derivation that understands how to build the rebar3 project. For
|
||||
example, the epression we use to build the <link
|
||||
xlink:href="https://github.com/erlang-nix/hex2nix">hex2nix</link>
|
||||
project follows.
|
||||
</para>
|
||||
<programlisting>
|
||||
{stdenv, fetchFromGitHub, buildRebar3, ibrowse, jsx, erlware_commons }:
|
||||
|
||||
buildRebar3 rec {
|
||||
name = "hex2nix";
|
||||
version = "0.0.1";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "ericbmerritt";
|
||||
repo = "hex2nix";
|
||||
rev = "${version}";
|
||||
sha256 = "1w7xjidz1l5yjmhlplfx7kphmnpvqm67w99hd2m7kdixwdxq0zqg";
|
||||
};
|
||||
|
||||
erlangDeps = [ ibrowse jsx erlware_commons ];
|
||||
}
|
||||
</programlisting>
|
||||
<para>
|
||||
The only visible difference between this derivation and
|
||||
something like <literal>stdenv.mkDerivation</literal> is that we
|
||||
have added <literal>erlangDeps</literal> to the derivation. If
|
||||
you add your Erlang dependencies here they will be correctly
|
||||
handled by the system.
|
||||
</para>
|
||||
<para>
|
||||
If your package needs to compile native code via Rebar's port
|
||||
compilation mechenism. You should add <literal>compilePort =
|
||||
true;</literal> to the derivation.
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section xml:id="hex-packages">
|
||||
<title>Hex Packages</title>
|
||||
<para>
|
||||
Hex packages are based on Rebar packages. In fact, at the moment
|
||||
we can only compile Hex packages that are buildable with
|
||||
Rebar3. Packages that use Mix and other build systems are not
|
||||
supported. That being said, we know a lot more about Hex and can
|
||||
do more for you.
|
||||
</para>
|
||||
<programlisting>
|
||||
{ buildHex }:
|
||||
buildHex {
|
||||
name = "esqlite";
|
||||
version = "0.2.1";
|
||||
sha256 = "1296fn1lz4lz4zqzn4dwc3flgkh0i6n4sydg501faabfbv8d3wkr";
|
||||
compilePort = true;
|
||||
}
|
||||
</programlisting>
|
||||
<para>
|
||||
For Hex packages you need to provide the name, the version, and
|
||||
the Sha 256 digest of the package and use
|
||||
<literal>buildHex</literal> to build it. Obviously, the package
|
||||
needs to have already been published to Hex.
|
||||
</para>
|
||||
</section>
|
||||
</section>
|
||||
<section xml:id="how-to-develop">
|
||||
<title>How to develop</title>
|
||||
<section xml:id="accessing-an-environment">
|
||||
<title>Accessing an Environment</title>
|
||||
<para>
|
||||
Often, all you want to do is be able to access a valid
|
||||
environment that contains a specific package and its
|
||||
dependencies. we can do that with the <literal>env</literal>
|
||||
part of a derivation. For example, lets say we want to access an
|
||||
erlang repl with ibrowse loaded up. We could do the following.
|
||||
</para>
|
||||
<programlisting>
|
||||
~/w/nixpkgs ❯❯❯ nix-shell -A erlangPackages.ibrowse.env --run "erl"
|
||||
Erlang/OTP 18 [erts-7.0] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]
|
||||
|
||||
Eshell V7.0 (abort with ^G)
|
||||
1> m(ibrowse).
|
||||
Module: ibrowse
|
||||
MD5: 3b3e0137d0cbb28070146978a3392945
|
||||
Compiled: January 10 2016, 23:34
|
||||
Object file: /nix/store/g1rlf65rdgjs4abbyj4grp37ry7ywivj-ibrowse-4.2.2/lib/erlang/lib/ibrowse-4.2.2/ebin/ibrowse.beam
|
||||
Compiler options: [{outdir,"/tmp/nix-build-ibrowse-4.2.2.drv-0/hex-source-ibrowse-4.2.2/_build/default/lib/ibrowse/ebin"},
|
||||
debug_info,debug_info,nowarn_shadow_vars,
|
||||
warn_unused_import,warn_unused_vars,warnings_as_errors,
|
||||
{i,"/tmp/nix-build-ibrowse-4.2.2.drv-0/hex-source-ibrowse-4.2.2/_build/default/lib/ibrowse/include"}]
|
||||
Exports:
|
||||
add_config/1 send_req_direct/7
|
||||
all_trace_off/0 set_dest/3
|
||||
code_change/3 set_max_attempts/3
|
||||
get_config_value/1 set_max_pipeline_size/3
|
||||
get_config_value/2 set_max_sessions/3
|
||||
get_metrics/0 show_dest_status/0
|
||||
get_metrics/2 show_dest_status/1
|
||||
handle_call/3 show_dest_status/2
|
||||
handle_cast/2 spawn_link_worker_process/1
|
||||
handle_info/2 spawn_link_worker_process/2
|
||||
init/1 spawn_worker_process/1
|
||||
module_info/0 spawn_worker_process/2
|
||||
module_info/1 start/0
|
||||
rescan_config/0 start_link/0
|
||||
rescan_config/1 stop/0
|
||||
send_req/3 stop_worker_process/1
|
||||
send_req/4 stream_close/1
|
||||
send_req/5 stream_next/1
|
||||
send_req/6 terminate/2
|
||||
send_req_direct/4 trace_off/0
|
||||
send_req_direct/5 trace_off/2
|
||||
send_req_direct/6 trace_on/0
|
||||
trace_on/2
|
||||
ok
|
||||
2>
|
||||
</programlisting>
|
||||
<para>
|
||||
Notice the <literal>-A erlangPackages.ibrowse.env</literal>.That
|
||||
is the key to this functionality.
|
||||
</para>
|
||||
</section>
|
||||
<section xml:id="creating-a-shell">
|
||||
<title>Creating a Shell</title>
|
||||
<para>
|
||||
Getting access to an environment often isn't enough to do real
|
||||
development. Many times we need to create a
|
||||
<literal>shell.nix</literal> file and do our development inside
|
||||
of the environment specified by that file. This file looks a lot
|
||||
like the packageing described above. The main difference is that
|
||||
<literal>src</literal> points to project root and we call the
|
||||
package directly.
|
||||
</para>
|
||||
<programlisting>
|
||||
{ pkgs ? import "<nixpkgs"> {} }:
|
||||
|
||||
with pkgs;
|
||||
|
||||
let
|
||||
|
||||
f = { buildHex, ibrowse, jsx, erlware_commons }:
|
||||
buildHex {
|
||||
name = "hex2nix";
|
||||
version = "0.1.0";
|
||||
src = ./.;
|
||||
erlangDeps = [ ibrowse jsx erlware_commons ];
|
||||
};
|
||||
drv = erlangPackages.callPackage f {};
|
||||
|
||||
in
|
||||
drv
|
||||
</programlisting>
|
||||
<section xml:id="building-in-a-shell">
|
||||
<title>Building in a shell</title>
|
||||
<para>
|
||||
Unfortunatly for us users of Nix, Rebar isn't very cooperative
|
||||
with us from the standpoint of building a hermetic
|
||||
environment. When building the rebar3 support we had to do some
|
||||
sneaky things to get it not to go out and pull packages on its
|
||||
own. Also unfortunately, you have to do some of the same things
|
||||
when building a project inside of a Nix shell.
|
||||
|
||||
<orderedlist numeration="arabic">
|
||||
<listitem>
|
||||
<para>Run <literal>rebar3-nix-bootstrap</literal> every time
|
||||
dependencies change</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Set Home to the current directory.</para>
|
||||
</listitem>
|
||||
</orderedlist>
|
||||
|
||||
If you do these two things then Rebar will be happy with you. I
|
||||
codify these into a makefile. Forunately, rebar3-nix-bootstrap
|
||||
is idempotent and fairly quick. so you can run it as often as
|
||||
you like.
|
||||
</para>
|
||||
<programlisting>
|
||||
# =============================================================================
|
||||
# Rules
|
||||
# =============================================================================
|
||||
.PHONY= all test clean repl shell build test analyze bootstrap
|
||||
|
||||
all: test
|
||||
|
||||
clean:
|
||||
rm -rf _build
|
||||
rm -rf .cache
|
||||
|
||||
repl:
|
||||
nix-shell --run "erl"
|
||||
|
||||
shell:
|
||||
nix-shell --run "bash"
|
||||
|
||||
bootstrap:
|
||||
nix-shell --pure --run "rebar3-nix-bootstrap"
|
||||
|
||||
build: bootstrap
|
||||
nix-shell --pure --run "HOME=$(CURDIR) rebar3 compile"
|
||||
|
||||
analyze: bootstrap
|
||||
nix-shell --pure --run "HOME=$(CURDIR) rebar3 do compile,dialyzer"
|
||||
|
||||
test: bootstrap
|
||||
nix-shell --pure --run "HOME=$(CURDIR) rebar3 do compile,dialyzer,eunit"
|
||||
|
||||
</programlisting>
|
||||
<para>
|
||||
If you add the <literal>shell.nix</literal> as described and
|
||||
user rebar as follows things should simply work.
|
||||
</para>
|
||||
</section>
|
||||
</section>
|
||||
</section>
|
||||
<section xml:id="generating-packages-from-hex-with-hex2nix">
|
||||
<title>Generating Packages from Hex with Hex2Nix</title>
|
||||
<para>
|
||||
Updating the Hex packages requires the use of the
|
||||
<literal>hex2nix</literal> tool. Given the path to the Erlang
|
||||
modules (usually
|
||||
<literal>pkgs/development/erlang-modules</literal>). It will
|
||||
happily dump a file called
|
||||
<literal>hex-packages.nix</literal>. That file will contain all
|
||||
the packages that use a recognized build system in Hex. However,
|
||||
it can't know whether or not all those packages are buildable.
|
||||
</para>
|
||||
<para>
|
||||
To make life easier for our users, it makes good sense to go
|
||||
ahead and attempt to build all those packages and remove the
|
||||
ones that don't build. To do that, simply run the command (in
|
||||
the root of your <literal>nixpkgs</literal> repository). that follows.
|
||||
</para>
|
||||
<programlisting>
|
||||
$ nix-build -A erlangPackages
|
||||
</programlisting>
|
||||
<para>
|
||||
That will build every package in
|
||||
<literal>erlangPackages</literal>. Then you can go through and
|
||||
manually remove the ones that fail. Hopefully, someone will
|
||||
improve <literal>hex2nix</literal> in the future to automate
|
||||
that.
|
||||
</para>
|
||||
</section>
|
||||
</chapter>
|
@ -20,6 +20,7 @@
|
||||
<xi:include href="coding-conventions.xml" />
|
||||
<xi:include href="submitting-changes.xml" />
|
||||
<xi:include href="haskell-users-guide.xml" />
|
||||
<xi:include href="erlang-users-guide.xml" />
|
||||
<xi:include href="contributing.xml" />
|
||||
|
||||
</book>
|
||||
|
@ -1,68 +0,0 @@
|
||||
# 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 }:
|
||||
|
||||
{ name, version
|
||||
, buildInputs ? [], erlangDeps ? []
|
||||
, postPatch ? ""
|
||||
, meta ? {}
|
||||
, ... }@attrs:
|
||||
|
||||
with stdenv.lib;
|
||||
|
||||
stdenv.mkDerivation (attrs // {
|
||||
name = "${name}-${version}";
|
||||
|
||||
buildInputs = buildInputs ++ [ erlang rebar openssl libyaml ];
|
||||
|
||||
postPatch = ''
|
||||
rm -f rebar
|
||||
if [ -e "src/${name}.app.src" ]; then
|
||||
sed -i -e 's/{ *vsn *,[^}]*}/{vsn, "${version}"}/' "src/${name}.app.src"
|
||||
fi
|
||||
${postPatch}
|
||||
'';
|
||||
|
||||
configurePhase = let
|
||||
getDeps = drv: [drv] ++ (map getDeps drv.erlangDeps);
|
||||
recursiveDeps = uniqList {
|
||||
inputList = flatten (map getDeps erlangDeps);
|
||||
};
|
||||
in ''
|
||||
runHook preConfigure
|
||||
${concatMapStrings (dep: ''
|
||||
header "linking erlang dependency ${dep}"
|
||||
mkdir deps
|
||||
ln -s "${dep}" "deps/${dep.packageName}"
|
||||
stopNest
|
||||
'') recursiveDeps}
|
||||
runHook postConfigure
|
||||
'';
|
||||
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
rebar compile
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
for reldir in src ebin priv include; do
|
||||
[ -e "$reldir" ] || continue
|
||||
mkdir "$out"
|
||||
cp -rt "$out" "$reldir"
|
||||
success=1
|
||||
done
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
meta = {
|
||||
inherit (erlang.meta) platforms;
|
||||
} // meta;
|
||||
|
||||
passthru = {
|
||||
packageName = name;
|
||||
inherit erlangDeps;
|
||||
};
|
||||
})
|
@ -1,109 +1,19 @@
|
||||
{ stdenv, erlang, rebar3, openssl, libyaml, fetchHex, fetchFromGitHub,
|
||||
rebar3-pc, buildEnv }:
|
||||
{ stdenv, buildRebar3, fetchHex }:
|
||||
|
||||
{ name, version, sha256
|
||||
, hexPkg ? name
|
||||
, buildInputs ? [], erlangDeps ? [], pluginDeps ? []
|
||||
, postPatch ? ""
|
||||
, compilePorts ? false
|
||||
, meta ? {}
|
||||
, ... }@attrs:
|
||||
|
||||
with stdenv.lib;
|
||||
|
||||
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}";
|
||||
|
||||
buildInputs = buildInputs ++ [ erlang rebar3 openssl libyaml ];
|
||||
pkg = self: buildRebar3 (attrs // {
|
||||
|
||||
src = fetchHex {
|
||||
pkg = hexPkg;
|
||||
inherit version;
|
||||
inherit sha256;
|
||||
};
|
||||
|
||||
postPatch = ''
|
||||
rm -f rebar rebar3
|
||||
if [ -e "src/${name}.app.src" ]; then
|
||||
sed -i -e 's/{ *vsn *,[^}]*}/{vsn, "${version}"}/' "src/${name}.app.src"
|
||||
fi
|
||||
|
||||
${if compilePorts then ''
|
||||
echo "{plugins, [pc]}." >> rebar.config
|
||||
'' else ''''}
|
||||
|
||||
${rebar3.setupRegistry}
|
||||
|
||||
${postPatch}
|
||||
'';
|
||||
|
||||
configurePhase = ''
|
||||
runHook preConfigure
|
||||
${concatMapStrings (dep: ''
|
||||
header "linking erlang dependency ${dep}"
|
||||
ln -s "${dep}/${dep.name}" "_build/default/lib/${dep.name}"
|
||||
stopNest
|
||||
'') recursiveDeps}
|
||||
${concatMapStrings (dep: ''
|
||||
header "linking rebar3 plugins ${dep}"
|
||||
ln -s "${dep}/${dep.name}" "_build/default/plugins/${dep.name}"
|
||||
stopNest
|
||||
'') recursivePluginsDeps}
|
||||
runHook postConfigure
|
||||
'';
|
||||
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
HOME=. rebar3 compile
|
||||
${if compilePorts then ''
|
||||
HOME=. rebar3 pc compile
|
||||
'' else ''''}
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
mkdir -p "$out/${name}"
|
||||
for reldir in src ebin priv include; do
|
||||
fd="_build/default/lib/${name}/$reldir"
|
||||
[ -d "$fd" ] || continue
|
||||
cp -Hrt "$out/${name}" "$fd"
|
||||
success=1
|
||||
done
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
meta = {
|
||||
inherit (erlang.meta) platforms;
|
||||
} // meta;
|
||||
|
||||
passthru = {
|
||||
packageName = name;
|
||||
env = shell self;
|
||||
inherit erlangDeps;
|
||||
};
|
||||
});
|
||||
in
|
||||
fix pkg
|
||||
|
85
pkgs/development/erlang-modules/build-rebar3.nix
Normal file
85
pkgs/development/erlang-modules/build-rebar3.nix
Normal file
@ -0,0 +1,85 @@
|
||||
{ stdenv, writeText, erlang, rebar3, openssl, libyaml, fetchHex, fetchFromGitHub,
|
||||
pc, buildEnv }:
|
||||
|
||||
{ name, version
|
||||
, src
|
||||
, setupHook ? null
|
||||
, buildInputs ? [], erlangDeps ? [], pluginDeps ? []
|
||||
, postPatch ? ""
|
||||
, compilePorts ? false
|
||||
, installPhase ? null
|
||||
, meta ? {}
|
||||
, ... }@attrs:
|
||||
|
||||
with stdenv.lib;
|
||||
|
||||
let
|
||||
plugins = pluginDeps ++ (if compilePorts then [pc] else []);
|
||||
|
||||
|
||||
shell = drv: stdenv.mkDerivation {
|
||||
name = "interactive-shell-${drv.name}";
|
||||
buildInputs = [ drv ];
|
||||
};
|
||||
|
||||
pkg = self: stdenv.mkDerivation (attrs // {
|
||||
|
||||
name = "${name}-${version}";
|
||||
inherit version;
|
||||
|
||||
buildInputs = buildInputs ++ [ erlang rebar3 openssl libyaml ];
|
||||
propagatedBuildInputs = erlangDeps ++ plugins;
|
||||
|
||||
inherit src;
|
||||
|
||||
setupHook = if setupHook == null
|
||||
then writeText "setupHook.sh" ''
|
||||
addToSearchPath ERL_LIBS "$1/lib/erlang/lib/"
|
||||
''
|
||||
else setupHook;
|
||||
|
||||
postPatch = ''
|
||||
rm -f rebar rebar3
|
||||
'';
|
||||
|
||||
configurePhase = ''
|
||||
runHook preConfigure
|
||||
rebar3-nix-bootstrap
|
||||
runHook postConfigure
|
||||
'';
|
||||
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
HOME=. rebar3 compile
|
||||
${if compilePorts then ''
|
||||
HOME=. rebar3 pc compile
|
||||
'' else ''''}
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
installPhase = if installPhase == null
|
||||
then ''
|
||||
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
|
||||
done
|
||||
runHook postInstall
|
||||
''
|
||||
else installPhase;
|
||||
|
||||
meta = {
|
||||
inherit (erlang.meta) platforms;
|
||||
} // meta;
|
||||
|
||||
passthru = {
|
||||
packageName = name;
|
||||
env = shell self;
|
||||
inherit erlangDeps;
|
||||
};
|
||||
});
|
||||
in
|
||||
fix pkg
|
@ -1,18 +1,14 @@
|
||||
{ pkgs }: #? import <nixpkgs> {} }:
|
||||
{ stdenv, pkgs }: #? import <nixpkgs> {} }:
|
||||
|
||||
let
|
||||
callPackage = pkgs.lib.callPackageWith (pkgs // self);
|
||||
|
||||
self = rec {
|
||||
buildErlang = callPackage ./build-erlang.nix {};
|
||||
hex = import ./hex-packages.nix { stdenv = stdenv; callPackage = self.callPackage; };
|
||||
callPackage = pkgs.lib.callPackageWith (pkgs // self // hex);
|
||||
|
||||
buildRebar3 = callPackage ./build-rebar3.nix {};
|
||||
buildHex = callPackage ./build-hex.nix {};
|
||||
|
||||
rebar3-pc = callPackage ./hex/rebar3-pc.nix {};
|
||||
esqlite = callPackage ./hex/esqlite.nix {};
|
||||
goldrush = callPackage ./hex/goldrush.nix {};
|
||||
ibrowse = callPackage ./hex/ibrowse.nix {};
|
||||
jiffy = callPackage ./hex/jiffy.nix {};
|
||||
lager = callPackage ./hex/lager.nix {};
|
||||
meck = callPackage ./hex/meck.nix {};
|
||||
## Non hex packages
|
||||
webdriver = callPackage ./webdriver {};
|
||||
};
|
||||
in self
|
||||
in self // self.hex
|
||||
|
3807
pkgs/development/erlang-modules/hex-packages.nix
Normal file
3807
pkgs/development/erlang-modules/hex-packages.nix
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,8 +0,0 @@
|
||||
{ buildHex, rebar3-pc }:
|
||||
|
||||
buildHex {
|
||||
name = "esqlite";
|
||||
version = "0.2.1";
|
||||
sha256 = "1296fn1lz4lz4zqzn4dwc3flgkh0i6n4sydg501faabfbv8d3wkr";
|
||||
compilePorts = true;
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
{ buildHex, fetchurl }:
|
||||
|
||||
buildHex {
|
||||
name = "goldrush";
|
||||
version = "0.1.7";
|
||||
sha256 = "1zjgbarclhh10cpgvfxikn9p2ay63rajq96q1sbz9r9w6v6p8jm9";
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
{ buildHex }:
|
||||
|
||||
buildHex {
|
||||
name = "ibrowse";
|
||||
version = "4.2.2";
|
||||
sha256 = "1bn0645n95j5zypdsns1w4kgd3q9lz8fj898hg355j5w89scn05q";
|
||||
}
|
||||
|
@ -1,8 +0,0 @@
|
||||
{ buildHex }:
|
||||
|
||||
buildHex {
|
||||
name = "jiffy";
|
||||
version = "0.14.5";
|
||||
hexPkg = "barrel_jiffy";
|
||||
sha256 = "0iqz8bp0f672c5rfy5dpw9agv2708wzldd00ngbsffglpinlr1wa";
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
{ buildHex, goldrush }:
|
||||
|
||||
buildHex {
|
||||
name = "lager";
|
||||
version = "3.0.2";
|
||||
sha256 = "0051zj6wfmmvxjn9q0nw8wic13nhbrkyy50cg1lcpdh17qiknzsj";
|
||||
erlangDeps = [ goldrush ];
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
{ stdenv, buildHex }:
|
||||
|
||||
buildHex {
|
||||
name = "meck";
|
||||
version = "0.8.3";
|
||||
sha256 = "1dh2rhks1xly4f49x89vbhsk8fgwkx5zqp0n98mnng8rs1rkigak";
|
||||
|
||||
meta = {
|
||||
description = "A mocking framework for Erlang";
|
||||
homepage = "https://github.com/eproxus/meck";
|
||||
license = stdenv.lib.licenses.apsl20;
|
||||
};
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
{ buildHex, goldrush }:
|
||||
|
||||
buildHex {
|
||||
name = "pc";
|
||||
version = "1.1.0";
|
||||
sha256 = "1br5xfl4b2z70b6a2ccxppn64jvkqgpmy4y9v81kxzb91z0ss9ma";
|
||||
}
|
40
pkgs/development/erlang-modules/webdriver/default.nix
Normal file
40
pkgs/development/erlang-modules/webdriver/default.nix
Normal file
@ -0,0 +1,40 @@
|
||||
{stdenv, fetchFromGitHub, writeText, erlang }:
|
||||
|
||||
let
|
||||
shell = drv: stdenv.mkDerivation {
|
||||
name = "interactive-shell-${drv.name}";
|
||||
buildInputs = [ drv ];
|
||||
};
|
||||
|
||||
pkg = self: stdenv.mkDerivation rec {
|
||||
name = "webdriver";
|
||||
version = "0.0.0+build.18.7ceaf1f";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "Quviq";
|
||||
repo = "webdrv";
|
||||
rev = "7ceaf1f67d834e841ca0133b4bf899a9fa2db6bb";
|
||||
sha256 = "1pq6pmlr6xb4hv2fvmlrvzd8c70kdcidlgjv4p8n9pwvkif0cb87";
|
||||
};
|
||||
|
||||
setupHook = writeText "setupHook.sh" ''
|
||||
addToSearchPath ERL_LIBS "$1/lib/erlang/lib/"
|
||||
'';
|
||||
|
||||
buildInputs = [ erlang ];
|
||||
|
||||
installFlags = "PREFIX=$(out)/lib/erlang/lib";
|
||||
|
||||
meta = {
|
||||
description = "WebDriver implementation in Erlang";
|
||||
license = stdenv.lib.licenses.mit;
|
||||
homepage = "https://github.com/Quviq/webdrv";
|
||||
maintainers = with stdenv.lib.maintainers; [ ericbmerritt ];
|
||||
};
|
||||
|
||||
passthru = {
|
||||
env = shell self;
|
||||
};
|
||||
|
||||
};
|
||||
in stdenv.lib.fix pkg
|
@ -1,13 +1,11 @@
|
||||
{ stdenv, fetchurl, fetchHex, erlang, tree, fetchFromGitHub }:
|
||||
{ stdenv, writeText, callPackage, fetchurl,
|
||||
fetchHex, erlang, rebar3-nix-bootstrap, tree, fetchFromGitHub }:
|
||||
|
||||
|
||||
let
|
||||
version = "3.0.0-beta.4";
|
||||
registrySnapshot = import ./registrySnapshot.nix { inherit fetchFromGitHub; };
|
||||
setupRegistry = ''
|
||||
mkdir -p _build/default/{lib,plugins,packages}/ ./.cache/rebar3/hex/default/
|
||||
zcat ${registrySnapshot}/registry.ets.gz > .cache/rebar3/hex/default/registry
|
||||
'';
|
||||
registrySnapshot = callPackage ./registrySnapshot.nix { };
|
||||
|
||||
# TODO: all these below probably should go into nixpkgs.erlangModules.sources.*
|
||||
# {erlware_commons, "0.16.0"},
|
||||
erlware_commons = fetchHex {
|
||||
@ -73,6 +71,7 @@ let
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
name = "rebar3-${version}";
|
||||
inherit version;
|
||||
|
||||
src = fetchurl {
|
||||
url = "https://github.com/rebar/rebar3/archive/${version}.tar.gz";
|
||||
@ -81,14 +80,14 @@ stdenv.mkDerivation {
|
||||
|
||||
patches = [ ./hermetic-bootstrap.patch ];
|
||||
|
||||
buildInputs = [ erlang
|
||||
tree
|
||||
];
|
||||
inherit setupRegistry;
|
||||
buildInputs = [ erlang tree ];
|
||||
propagatedBuildInputs = [ registrySnapshot rebar3-nix-bootstrap ];
|
||||
|
||||
|
||||
postPatch = ''
|
||||
echo postPatch
|
||||
${setupRegistry}
|
||||
rebar3-nix-bootstrap registry-only
|
||||
echo "$ERL_LIBS"
|
||||
mkdir -p _build/default/lib/
|
||||
cp --no-preserve=mode -R ${erlware_commons} _build/default/lib/erlware_commons
|
||||
cp --no-preserve=mode -R ${providers} _build/default/lib/providers
|
||||
|
@ -1,8 +1,23 @@
|
||||
{ fetchFromGitHub }:
|
||||
{stdenv, writeText, fetchFromGitHub }:
|
||||
|
||||
fetchFromGitHub {
|
||||
owner = "gleber";
|
||||
repo = "hex-pm-registry-snapshots";
|
||||
rev = "329ae2b";
|
||||
sha256 = "1rs3z8psfvy10mzlfvkdzbflgikcnq08r38kfi0f8p5wvi8f8hmh";
|
||||
stdenv.mkDerivation rec {
|
||||
name = "hex-registry";
|
||||
rev = "329ae2b";
|
||||
version = "0.0.0+build.${rev}";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "erlang-nix";
|
||||
repo = "hex-pm-registry-snapshots";
|
||||
inherit rev;
|
||||
sha256 = "1rs3z8psfvy10mzlfvkdzbflgikcnq08r38kfi0f8p5wvi8f8hmh";
|
||||
};
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p "$out/var/hex"
|
||||
zcat "registry.ets.gz" > "$out/var/hex/registry.ets"
|
||||
'';
|
||||
|
||||
setupHook = writeText "setupHook.sh" ''
|
||||
export HEX_REGISTRY_SNAPSHOT="$1/var/hex/registry.ets"
|
||||
'';
|
||||
}
|
||||
|
23
pkgs/development/tools/erlang/hex2nix/default.nix
Normal file
23
pkgs/development/tools/erlang/hex2nix/default.nix
Normal file
@ -0,0 +1,23 @@
|
||||
{stdenv, fetchFromGitHub, buildRebar3, ibrowse, jsx, erlware_commons, getopt }:
|
||||
|
||||
buildRebar3 rec {
|
||||
name = "hex2nix";
|
||||
version = "0.0.2";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "erlang-nix";
|
||||
repo = "hex2nix";
|
||||
rev = "${version}";
|
||||
sha256 = "18gkq5fkdiwq5zj98cz4kqxbpzjkpqcplpsw987drxwdbvq4hkwm";
|
||||
};
|
||||
|
||||
erlangDeps = [ ibrowse jsx erlware_commons getopt ];
|
||||
|
||||
DEBUG=1;
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
make PREFIX=$out install
|
||||
runHook postInstall
|
||||
'';
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
{stdenv, fetchFromGitHub }:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
name = "rebar3-nix-bootstrap";
|
||||
version = "0.0.1";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "erlang-nix";
|
||||
repo = "rebar3-nix-bootstrap";
|
||||
rev = "${version}";
|
||||
sha256 = "0xyj7j59dmxyl5nhhsmb0r1pihmk0s4k02ga1rfgm30rij6n7431";
|
||||
};
|
||||
|
||||
installFlags = "PREFIX=$(out)";
|
||||
|
||||
meta = {
|
||||
description = "Shim command to help bootstrap a rebar3 project on Nix";
|
||||
license = stdenv.lib.licenses.asl20;
|
||||
homepage = "https://github.com/erl-nix/rebar3-nix-bootstrap";
|
||||
maintainers = with stdenv.lib.maintainers; [ ericbmerritt ];
|
||||
};
|
||||
}
|
@ -5098,9 +5098,11 @@ let
|
||||
|
||||
rebar = callPackage ../development/tools/build-managers/rebar { };
|
||||
rebar3 = callPackage ../development/tools/build-managers/rebar3 { };
|
||||
rebar3-nix-bootstrap = callPackage ../development/tools/erlang/rebar3-nix-bootstrap { };
|
||||
fetchHex = callPackage ../development/tools/build-managers/rebar3/fetch-hex.nix { };
|
||||
|
||||
erlangPackages = callPackage ../development/erlang-modules { };
|
||||
hex2nix = erlangPackages.callPackage ../development/tools/erlang/hex2nix { };
|
||||
|
||||
elixir = callPackage ../development/interpreters/elixir { };
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user