2021-01-25 08:26:54 +00:00
|
|
|
{ lib, fetchFromGitHub, erlang, makeWrapper, coreutils, bash, buildRebar3, buildHex }:
|
2016-11-23 22:03:23 +00:00
|
|
|
|
2017-07-11 00:25:12 +00:00
|
|
|
{ baseName ? "lfe"
|
|
|
|
, version
|
2017-07-12 14:01:40 +00:00
|
|
|
, maximumOTPVersion
|
2017-07-11 00:25:12 +00:00
|
|
|
, sha256 ? null
|
|
|
|
, rev ? version
|
|
|
|
, src ? fetchFromGitHub { inherit rev sha256; owner = "rvirding"; repo = "lfe"; }
|
2020-01-30 18:00:09 +00:00
|
|
|
, patches ? []
|
2017-07-11 00:25:12 +00:00
|
|
|
}:
|
2016-11-23 22:03:23 +00:00
|
|
|
|
2017-07-11 18:16:48 +00:00
|
|
|
let
|
2021-01-23 13:15:07 +00:00
|
|
|
inherit (lib)
|
2020-01-30 18:00:09 +00:00
|
|
|
assertMsg makeBinPath optionalString
|
|
|
|
getVersion versionAtLeast versionOlder versions;
|
2017-07-12 14:01:40 +00:00
|
|
|
|
2019-09-24 09:24:13 +00:00
|
|
|
mainVersion = versions.major (getVersion erlang);
|
2017-07-12 14:01:40 +00:00
|
|
|
|
2017-07-11 18:16:48 +00:00
|
|
|
proper = buildHex {
|
|
|
|
name = "proper";
|
|
|
|
version = "1.1.1-beta";
|
|
|
|
|
|
|
|
sha256 = "0hnkhs761yjynw9382w8wm4j3x0r7lllzavaq2kh9n7qy3zc1rdx";
|
|
|
|
|
|
|
|
configurePhase = ''
|
|
|
|
${erlang}/bin/escript write_compile_flags include/compile_flags.hrl
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
in
|
2020-01-30 17:58:17 +00:00
|
|
|
assert (assertMsg (versionAtLeast maximumOTPVersion mainVersion)) ''
|
|
|
|
LFE ${version} is supported on OTP <=${maximumOTPVersion}, not ${mainVersion}.
|
|
|
|
'';
|
2017-07-11 18:16:48 +00:00
|
|
|
|
2017-07-11 00:25:12 +00:00
|
|
|
buildRebar3 {
|
2017-07-11 18:16:48 +00:00
|
|
|
name = baseName;
|
2016-07-12 11:48:33 +00:00
|
|
|
|
2017-07-11 00:25:12 +00:00
|
|
|
inherit src version;
|
2016-07-12 11:48:33 +00:00
|
|
|
|
2017-07-11 00:25:12 +00:00
|
|
|
buildInputs = [ erlang makeWrapper ];
|
2017-07-11 18:16:48 +00:00
|
|
|
beamDeps = [ proper ];
|
2020-01-30 18:00:09 +00:00
|
|
|
patches = [ ./no-test-deps.patch ./dedup-ebins.patch ] ++ patches;
|
2017-07-11 18:16:48 +00:00
|
|
|
doCheck = true;
|
|
|
|
checkTarget = "travis";
|
2016-07-12 11:48:33 +00:00
|
|
|
|
2020-01-30 18:00:09 +00:00
|
|
|
makeFlags = [ "-e" "MANDB=''" "PREFIX=$$out"];
|
|
|
|
|
2016-07-12 11:48:33 +00:00
|
|
|
# These installPhase tricks are based on Elixir's Makefile.
|
|
|
|
# TODO: Make, upload, and apply a patch.
|
2020-01-30 18:00:09 +00:00
|
|
|
installPhase = optionalString (versionOlder version "1.3") ''
|
2016-07-12 11:48:33 +00:00
|
|
|
local libdir=$out/lib/lfe
|
|
|
|
local ebindir=$libdir/ebin
|
|
|
|
local bindir=$libdir/bin
|
|
|
|
|
|
|
|
rm -Rf $ebindir
|
|
|
|
install -m755 -d $ebindir
|
2016-11-23 22:03:23 +00:00
|
|
|
install -m644 _build/default/lib/lfe/ebin/* $ebindir
|
2016-07-12 11:48:33 +00:00
|
|
|
|
|
|
|
install -m755 -d $bindir
|
2017-07-11 00:25:12 +00:00
|
|
|
|
2016-07-12 11:48:33 +00:00
|
|
|
for bin in bin/lfe{,c,doc,script}; do install -m755 $bin $bindir; done
|
|
|
|
|
|
|
|
install -m755 -d $out/bin
|
|
|
|
for file in $bindir/*; do ln -sf $file $out/bin/; done
|
|
|
|
'';
|
|
|
|
|
|
|
|
# Thanks again, Elixir.
|
|
|
|
postFixup = ''
|
|
|
|
# LFE binaries are shell scripts which run erl and lfe.
|
|
|
|
# Add some stuff to PATH so the scripts can run without problems.
|
|
|
|
for f in $out/bin/*; do
|
|
|
|
wrapProgram $f \
|
2020-01-30 18:00:09 +00:00
|
|
|
--prefix PATH ":" "${makeBinPath [ erlang coreutils bash ]}:$out/bin"
|
2016-07-12 11:48:33 +00:00
|
|
|
substituteInPlace $f --replace "/usr/bin/env" "${coreutils}/bin/env"
|
|
|
|
done
|
|
|
|
'';
|
|
|
|
|
2021-01-23 13:15:07 +00:00
|
|
|
meta = with lib; {
|
2016-07-12 11:48:33 +00:00
|
|
|
description = "The best of Erlang and of Lisp; at the same time!";
|
|
|
|
longDescription = ''
|
|
|
|
LFE, Lisp Flavoured Erlang, is a lisp syntax front-end to the Erlang
|
|
|
|
compiler. Code produced with it is compatible with "normal" Erlang
|
|
|
|
code. An LFE evaluator and shell is also included.
|
|
|
|
'';
|
|
|
|
|
|
|
|
homepage = "http://lfe.io";
|
|
|
|
downloadPage = "https://github.com/rvirding/lfe/releases";
|
|
|
|
|
|
|
|
license = licenses.asl20;
|
2021-01-23 20:25:40 +00:00
|
|
|
maintainers = teams.beam.members;
|
2016-07-12 11:48:33 +00:00
|
|
|
platforms = platforms.unix;
|
|
|
|
};
|
|
|
|
}
|