at master 2.9 kB view raw
1{ 2 stdenv, 3 writeText, 4 erlang, 5 perl, 6 which, 7 gitMinimal, 8 wget, 9 lib, 10}: 11 12{ 13 name, 14 version, 15 src, 16 setupHook ? null, 17 buildInputs ? [ ], 18 beamDeps ? [ ], 19 postPatch ? "", 20 compilePorts ? false, 21 installPhase ? null, 22 buildPhase ? null, 23 configurePhase ? null, 24 meta ? { }, 25 enableDebugInfo ? false, 26 buildFlags ? [ ], 27 ... 28}@attrs: 29 30let 31 debugInfoFlag = lib.optionalString (enableDebugInfo || erlang.debugInfo) "+debug_info"; 32 33 shell = 34 drv: 35 stdenv.mkDerivation { 36 name = "interactive-shell-${drv.name}"; 37 buildInputs = [ drv ]; 38 }; 39 40 pkg = 41 self: 42 stdenv.mkDerivation ( 43 attrs 44 // { 45 app_name = name; 46 name = "${name}-${version}"; 47 inherit version; 48 49 dontStrip = true; 50 51 inherit src; 52 53 setupHook = 54 if setupHook == null then 55 writeText "setupHook.sh" '' 56 addToSearchPath ERL_LIBS "$1/lib/erlang/lib" 57 '' 58 else 59 setupHook; 60 61 buildInputs = buildInputs ++ [ 62 erlang 63 perl 64 which 65 gitMinimal 66 wget 67 ]; 68 propagatedBuildInputs = beamDeps; 69 70 buildFlags = [ 71 "SKIP_DEPS=1" 72 ] 73 ++ lib.optional (enableDebugInfo || erlang.debugInfo) ''ERL_OPTS="$ERL_OPTS +debug_info"'' 74 ++ buildFlags; 75 76 configurePhase = 77 if configurePhase == null then 78 '' 79 runHook preConfigure 80 81 # We shouldnt need to do this, but it seems at times there is a *.app in 82 # the repo/package. This ensures we start from a clean slate 83 make SKIP_DEPS=1 clean 84 85 runHook postConfigure 86 '' 87 else 88 configurePhase; 89 90 buildPhase = 91 if buildPhase == null then 92 '' 93 runHook preBuild 94 95 make $buildFlags "''${buildFlagsArray[@]}" 96 97 runHook postBuild 98 '' 99 else 100 buildPhase; 101 102 installPhase = 103 if installPhase == null then 104 '' 105 runHook preInstall 106 107 mkdir -p $out/lib/erlang/lib/${name} 108 cp -r ebin $out/lib/erlang/lib/${name}/ 109 cp -r src $out/lib/erlang/lib/${name}/ 110 111 if [ -d include ]; then 112 cp -r include $out/lib/erlang/lib/${name}/ 113 fi 114 115 if [ -d priv ]; then 116 cp -r priv $out/lib/erlang/lib/${name}/ 117 fi 118 119 if [ -d doc ]; then 120 cp -r doc $out/lib/erlang/lib/${name}/ 121 fi 122 123 runHook postInstall 124 '' 125 else 126 installPhase; 127 128 passthru = { 129 packageName = name; 130 env = shell self; 131 inherit beamDeps; 132 }; 133 } 134 ); 135in 136lib.fix pkg