1{ stdenv, fetchFromGitHub, erlang, makeWrapper, coreutils, bash }:
2
3stdenv.mkDerivation rec {
4 name = "lfe-${version}";
5 version = "1.1.1";
6
7 src = fetchFromGitHub {
8 owner = "rvirding";
9 repo = "lfe";
10 rev = version;
11 sha256 = "0w1vpjqj8ni43gi84i0mcml4gfaqhmmd9s46di37cngpdw86i3bz";
12 };
13
14 buildInputs = [ erlang makeWrapper ];
15
16 setupHook = ./setup-hook.sh;
17
18 # These installPhase tricks are based on Elixir's Makefile.
19 # TODO: Make, upload, and apply a patch.
20 installPhase = ''
21 local libdir=$out/lib/lfe
22 local ebindir=$libdir/ebin
23 local bindir=$libdir/bin
24
25 rm -Rf $ebindir
26 install -m755 -d $ebindir
27 install -m644 ebin/* $ebindir
28
29 install -m755 -d $bindir
30 for bin in bin/lfe{,c,doc,script}; do install -m755 $bin $bindir; done
31
32 install -m755 -d $out/bin
33 for file in $bindir/*; do ln -sf $file $out/bin/; done
34 '';
35
36 # Thanks again, Elixir.
37 postFixup = ''
38 # LFE binaries are shell scripts which run erl and lfe.
39 # Add some stuff to PATH so the scripts can run without problems.
40 for f in $out/bin/*; do
41 wrapProgram $f \
42 --prefix PATH ":" "${stdenv.lib.makeBinPath [ erlang coreutils bash ]}:$out/bin"
43 substituteInPlace $f --replace "/usr/bin/env" "${coreutils}/bin/env"
44 done
45 '';
46
47 meta = with stdenv.lib; {
48 description = "The best of Erlang and of Lisp; at the same time!";
49 longDescription = ''
50 LFE, Lisp Flavoured Erlang, is a lisp syntax front-end to the Erlang
51 compiler. Code produced with it is compatible with "normal" Erlang
52 code. An LFE evaluator and shell is also included.
53 '';
54
55 homepage = "http://lfe.io";
56 downloadPage = "https://github.com/rvirding/lfe/releases";
57
58 license = licenses.asl20;
59 maintainers = with maintainers; [ yurrriq ];
60 platforms = platforms.unix;
61 };
62}