Merge pull request #119126 from fabaff/pycomfoconnect
[NixPkgs.git] / pkgs / development / interpreters / lfe / generic-builder.nix
blob397be81e7c85aeade19f51bf67de7c67c3e0c14e
1 { lib, fetchFromGitHub, erlang, makeWrapper, coreutils, bash, buildRebar3, buildHex }:
3 { baseName ? "lfe"
4 , version
5 , maximumOTPVersion
6 , sha256 ? null
7 , rev ? version
8 , src ? fetchFromGitHub { inherit rev sha256; owner = "rvirding"; repo = "lfe"; }
9 , patches ? []
12 let
13   inherit (lib)
14     assertMsg makeBinPath optionalString
15     getVersion versionAtLeast versionOlder versions;
17   mainVersion = versions.major (getVersion erlang);
19   proper = buildHex {
20     name = "proper";
21     version = "1.1.1-beta";
23     sha256  = "0hnkhs761yjynw9382w8wm4j3x0r7lllzavaq2kh9n7qy3zc1rdx";
25     configurePhase = ''
26       ${erlang}/bin/escript write_compile_flags include/compile_flags.hrl
27     '';
28   };
31 assert (assertMsg (versionAtLeast maximumOTPVersion mainVersion)) ''
32   LFE ${version} is supported on OTP <=${maximumOTPVersion}, not ${mainVersion}.
33 '';
35 buildRebar3 {
36   name = baseName;
38   inherit src version;
40   buildInputs = [ erlang makeWrapper ];
41   beamDeps    = [ proper ];
42   patches     = [ ./no-test-deps.patch ./dedup-ebins.patch ] ++ patches;
43   doCheck     = true;
44   checkTarget = "travis";
46   makeFlags = [ "-e" "MANDB=''" "PREFIX=$$out"];
48   # These installPhase tricks are based on Elixir's Makefile.
49   # TODO: Make, upload, and apply a patch.
50   installPhase = optionalString (versionOlder version "1.3") ''
51     local libdir=$out/lib/lfe
52     local ebindir=$libdir/ebin
53     local bindir=$libdir/bin
55     rm -Rf $ebindir
56     install -m755 -d $ebindir
57     install -m644 _build/default/lib/lfe/ebin/* $ebindir
59     install -m755 -d $bindir
61     for bin in bin/lfe{,c,doc,script}; do install -m755 $bin $bindir; done
63     install -m755 -d $out/bin
64     for file in $bindir/*; do ln -sf $file $out/bin/; done
65   '';
67   # Thanks again, Elixir.
68   postFixup = ''
69     # LFE binaries are shell scripts which run erl and lfe.
70     # Add some stuff to PATH so the scripts can run without problems.
71     for f in $out/bin/*; do
72       wrapProgram $f \
73         --prefix PATH ":" "${makeBinPath [ erlang coreutils bash ]}:$out/bin"
74       substituteInPlace $f --replace "/usr/bin/env" "${coreutils}/bin/env"
75     done
76   '';
78   meta = with lib; {
79     description     = "The best of Erlang and of Lisp; at the same time!";
80     longDescription = ''
81       LFE, Lisp Flavoured Erlang, is a lisp syntax front-end to the Erlang
82       compiler. Code produced with it is compatible with "normal" Erlang
83       code. An LFE evaluator and shell is also included.
84     '';
86     homepage     = "http://lfe.io";
87     downloadPage = "https://github.com/rvirding/lfe/releases";
89     license      = licenses.asl20;
90     maintainers  = teams.beam.members;
91     platforms    = platforms.unix;
92   };