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