2021-02-05 17:12:51 +00:00
|
|
|
{ lib, fetchFromGitHub, erlang, makeWrapper, coreutils, bash, buildRebar3, buildHex }:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
{ baseName ? "lfe"
|
|
|
|
, version
|
|
|
|
, maximumOTPVersion
|
2024-02-07 01:22:34 +00:00
|
|
|
, sha256 ? ""
|
|
|
|
, hash ? ""
|
2020-04-24 23:36:52 +00:00
|
|
|
, rev ? version
|
2024-02-07 01:22:34 +00:00
|
|
|
, src ? fetchFromGitHub { inherit hash rev sha256; owner = "lfe"; repo = "lfe"; }
|
2020-04-24 23:36:52 +00:00
|
|
|
, patches ? []
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2021-02-05 17:12:51 +00:00
|
|
|
inherit (lib)
|
2020-04-24 23:36:52 +00:00
|
|
|
assertMsg makeBinPath optionalString
|
|
|
|
getVersion versionAtLeast versionOlder versions;
|
|
|
|
|
|
|
|
mainVersion = versions.major (getVersion erlang);
|
|
|
|
|
|
|
|
proper = buildHex {
|
|
|
|
name = "proper";
|
2023-03-24 00:07:29 +00:00
|
|
|
version = "1.4.0";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-03-24 00:07:29 +00:00
|
|
|
sha256 = "sha256-GChYQhhb0z772pfRNKXLWgiEOE2zYRn+4OPPpIhWjLs=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
in
|
|
|
|
assert (assertMsg (versionAtLeast maximumOTPVersion mainVersion)) ''
|
|
|
|
LFE ${version} is supported on OTP <=${maximumOTPVersion}, not ${mainVersion}.
|
|
|
|
'';
|
|
|
|
|
|
|
|
buildRebar3 {
|
|
|
|
name = baseName;
|
|
|
|
|
|
|
|
inherit src version;
|
|
|
|
|
2022-09-09 14:08:57 +00:00
|
|
|
nativeBuildInputs = [ makeWrapper erlang ];
|
2020-04-24 23:36:52 +00:00
|
|
|
beamDeps = [ proper ];
|
2021-05-20 23:08:51 +00:00
|
|
|
patches = [ ./fix-rebar-config.patch ./dedup-ebins.patch ] ++ patches;
|
2020-04-24 23:36:52 +00:00
|
|
|
doCheck = true;
|
|
|
|
checkTarget = "travis";
|
|
|
|
|
|
|
|
makeFlags = [ "-e" "MANDB=''" "PREFIX=$$out"];
|
|
|
|
|
|
|
|
# These installPhase tricks are based on Elixir's Makefile.
|
|
|
|
# TODO: Make, upload, and apply a patch.
|
|
|
|
installPhase = optionalString (versionOlder version "1.3") ''
|
|
|
|
local libdir=$out/lib/lfe
|
|
|
|
local ebindir=$libdir/ebin
|
|
|
|
local bindir=$libdir/bin
|
|
|
|
|
|
|
|
rm -Rf $ebindir
|
|
|
|
install -m755 -d $ebindir
|
|
|
|
install -m644 _build/default/lib/lfe/ebin/* $ebindir
|
|
|
|
|
|
|
|
install -m755 -d $bindir
|
|
|
|
|
|
|
|
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 \
|
|
|
|
--prefix PATH ":" "${makeBinPath [ erlang coreutils bash ]}:$out/bin"
|
|
|
|
substituteInPlace $f --replace "/usr/bin/env" "${coreutils}/bin/env"
|
|
|
|
done
|
|
|
|
'';
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +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.
|
|
|
|
'';
|
|
|
|
|
2021-12-30 13:39:12 +00:00
|
|
|
homepage = "https://lfe.io";
|
2020-04-24 23:36:52 +00:00
|
|
|
downloadPage = "https://github.com/rvirding/lfe/releases";
|
|
|
|
|
|
|
|
license = licenses.asl20;
|
2021-02-13 14:23:35 +00:00
|
|
|
maintainers = teams.beam.members;
|
2020-04-24 23:36:52 +00:00
|
|
|
platforms = platforms.unix;
|
|
|
|
};
|
|
|
|
}
|