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