1{ stdenv, fetchurl, erlang, rebar, makeWrapper, coreutils, curl, bash }:
2
3stdenv.mkDerivation rec {
4 name = "elixir-${version}";
5 version = "1.2.2";
6
7 src = fetchurl {
8 url = "https://github.com/elixir-lang/elixir/archive/v${version}.tar.gz";
9 sha256 = "0ml0sl1l5ibb8qh505fsd7y87wq9qjvaxw9y1dyfcw00d3i1z989";
10 };
11
12 buildInputs = [ erlang rebar makeWrapper ];
13
14 # Elixir expects that UTF-8 locale to be set (see https://github.com/elixir-lang/elixir/issues/3548).
15 # In other cases there is warnings during compilation.
16 LANG = "en_US.UTF-8";
17 LC_TYPE = "en_US.UTF-8";
18
19 preBuild = ''
20 # The build process uses ./rebar. Link it to the nixpkgs rebar
21 rm -v rebar
22 ln -s ${rebar}/bin/rebar rebar
23
24 substituteInPlace Makefile \
25 --replace "/usr/local" $out
26 '';
27
28 postFixup = ''
29 # Elixir binaries are shell scripts which run erl. Add some stuff
30 # to PATH so the scripts can run without problems.
31
32 for f in $out/bin/*; do
33 b=$(basename $f)
34 if [ $b == "mix" ]; then continue; fi
35 wrapProgram $f \
36 --prefix PATH ":" "${erlang}/bin:${coreutils}/bin:${curl}/bin:${bash}/bin" \
37 --set CURL_CA_BUNDLE /etc/ssl/certs/ca-certificates.crt
38 done
39
40 substituteInPlace $out/bin/mix \
41 --replace "/usr/bin/env elixir" "${coreutils}/bin/env elixir"
42 '';
43
44 meta = with stdenv.lib; {
45 homepage = "http://elixir-lang.org/";
46 description = "A functional, meta-programming aware language built on top of the Erlang VM";
47
48 longDescription = ''
49 Elixir is a functional, meta-programming aware language built on
50 top of the Erlang VM. It is a dynamic language with flexible
51 syntax and macro support that leverages Erlang's abilities to
52 build concurrent, distributed and fault-tolerant applications
53 with hot code upgrades.
54 '';
55
56 license = licenses.epl10;
57 platforms = platforms.unix;
58 maintainers = with maintainers; [ the-kenny havvy couchemar ];
59 };
60}