Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at netboot-syslinux-multiplatform 89 lines 2.6 kB view raw
1{ lib, fetchFromGitHub, erlang, makeWrapper, coreutils, bash, buildRebar3, buildHex }: 2 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 ? [] 10}: 11 12let 13 inherit (lib) 14 assertMsg makeBinPath optionalString 15 getVersion versionAtLeast versionOlder versions; 16 17 mainVersion = versions.major (getVersion erlang); 18 19 proper = buildHex { 20 name = "proper"; 21 version = "1.4.0"; 22 23 sha256 = "sha256-GChYQhhb0z772pfRNKXLWgiEOE2zYRn+4OPPpIhWjLs="; 24 }; 25 26in 27assert (assertMsg (versionAtLeast maximumOTPVersion mainVersion)) '' 28 LFE ${version} is supported on OTP <=${maximumOTPVersion}, not ${mainVersion}. 29''; 30 31buildRebar3 { 32 name = baseName; 33 34 inherit src version; 35 36 nativeBuildInputs = [ makeWrapper erlang ]; 37 beamDeps = [ proper ]; 38 patches = [ ./fix-rebar-config.patch ./dedup-ebins.patch ] ++ patches; 39 doCheck = true; 40 checkTarget = "travis"; 41 42 makeFlags = [ "-e" "MANDB=''" "PREFIX=$$out"]; 43 44 # These installPhase tricks are based on Elixir's Makefile. 45 # TODO: Make, upload, and apply a patch. 46 installPhase = optionalString (versionOlder version "1.3") '' 47 local libdir=$out/lib/lfe 48 local ebindir=$libdir/ebin 49 local bindir=$libdir/bin 50 51 rm -Rf $ebindir 52 install -m755 -d $ebindir 53 install -m644 _build/default/lib/lfe/ebin/* $ebindir 54 55 install -m755 -d $bindir 56 57 for bin in bin/lfe{,c,doc,script}; do install -m755 $bin $bindir; done 58 59 install -m755 -d $out/bin 60 for file in $bindir/*; do ln -sf $file $out/bin/; done 61 ''; 62 63 # Thanks again, Elixir. 64 postFixup = '' 65 # LFE binaries are shell scripts which run erl and lfe. 66 # Add some stuff to PATH so the scripts can run without problems. 67 for f in $out/bin/*; do 68 wrapProgram $f \ 69 --prefix PATH ":" "${makeBinPath [ erlang coreutils bash ]}:$out/bin" 70 substituteInPlace $f --replace "/usr/bin/env" "${coreutils}/bin/env" 71 done 72 ''; 73 74 meta = with lib; { 75 description = "The best of Erlang and of Lisp; at the same time!"; 76 longDescription = '' 77 LFE, Lisp Flavoured Erlang, is a lisp syntax front-end to the Erlang 78 compiler. Code produced with it is compatible with "normal" Erlang 79 code. An LFE evaluator and shell is also included. 80 ''; 81 82 homepage = "https://lfe.io"; 83 downloadPage = "https://github.com/rvirding/lfe/releases"; 84 85 license = licenses.asl20; 86 maintainers = teams.beam.members; 87 platforms = platforms.unix; 88 }; 89}