anvil-editor: init at 0.4
[NixPkgs.git] / pkgs / development / interpreters / elixir / generic-builder.nix
blobe1e14f14dee19f6e69dfbeea60cd67717fb5881e
1 { pkgs
2 , lib
3 , stdenv
4 , fetchFromGitHub
5 , erlang
6 , makeWrapper
7 , coreutils
8 , curl
9 , bash
10 , debugInfo ? false
11 } @ inputs:
13 { baseName ? "elixir"
14 , version
15 , erlang ? inputs.erlang
16 , minimumOTPVersion
17 , sha256 ? null
18 , rev ? "v${version}"
19 , src ? fetchFromGitHub { inherit rev sha256; owner = "elixir-lang"; repo = "elixir"; }
20 , escriptPath ? "lib/elixir/generate_app.escript"
21 } @ args:
23 let
24   inherit (lib) getVersion versionAtLeast optional concatStringsSep;
27 assert versionAtLeast (getVersion erlang) minimumOTPVersion;
29 stdenv.mkDerivation ({
30   pname = "${baseName}";
32   inherit src version debugInfo;
34   nativeBuildInputs = [ makeWrapper ];
35   buildInputs = [ erlang ];
37   LANG = "C.UTF-8";
38   LC_TYPE = "C.UTF-8";
40   ERLC_OPTS =
41     let
42       erlc_opts = [ "deterministic" ]
43         ++ optional debugInfo "debug_info";
44     in
45     "[${concatStringsSep "," erlc_opts}]";
47   preBuild = ''
48     patchShebangs ${escriptPath} || true
50     substituteInPlace Makefile \
51       --replace "/usr/local" $out
52   '';
54   postFixup = ''
55     # Elixir binaries are shell scripts which run erl. Add some stuff
56     # to PATH so the scripts can run without problems.
58     for f in $out/bin/*; do
59       b=$(basename $f)
60       if [ "$b" = mix ]; then continue; fi
61       wrapProgram $f \
62         --prefix PATH ":" "${lib.makeBinPath [ erlang coreutils curl bash ]}"
63     done
65     substituteInPlace $out/bin/mix \
66       --replace "/usr/bin/env elixir" "${coreutils}/bin/env $out/bin/elixir"
67   '';
69   pos = builtins.unsafeGetAttrPos "sha256" args;
70   meta = with lib; {
71     homepage = "https://elixir-lang.org/";
72     description = "Functional, meta-programming aware language built on top of the Erlang VM";
74     longDescription = ''
75       Elixir is a functional, meta-programming aware language built on
76       top of the Erlang VM. It is a dynamic language with flexible
77       syntax and macro support that leverages Erlang's abilities to
78       build concurrent, distributed and fault-tolerant applications
79       with hot code upgrades.
80     '';
82     license = licenses.epl10;
83     platforms = platforms.unix;
84     maintainers = teams.beam.members;
85   };