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