1# The standard set of gems in nixpkgs including potential fixes.
2#
3# The gemset is derived from two points of entry:
4# - An attrset describing a gem, including version, source and dependencies
5# This is just meta data, most probably automatically generated by a tool
6# like Bundix (https://github.com/aflatter/bundix).
7# {
8# name = "bundler";
9# version = "1.6.5";
10# sha256 = "1s4x0f5by9xs2y24jk6krq5ky7ffkzmxgr4z1nhdykdmpsi2zd0l";
11# dependencies = [ "rake" ];
12# }
13# - An optional derivation that may override how the gem is built. For popular
14# gems that don't behave correctly, fixes are already provided in the form of
15# derivations.
16#
17# This seperates "what to build" (the exact gem versions) from "how to build"
18# (to make gems behave if necessary).
19
20{ lib, fetchurl, writeScript, ruby, kerberos, libxml2, libxslt, python, stdenv, which
21, libiconv, postgresql, v8_3_16_14, clang, sqlite, zlib, imagemagick
22, pkgconfig , ncurses, xapian_1_2_22, gpgme, utillinux, fetchpatch, tzdata, icu, libffi
23, cmake, libssh2, openssl, mysql, darwin, git, perl, pcre, gecode_3, curl
24, msgpack, qt48, libsodium, snappy, libossp_uuid, lxc, libpcap, xorg, gtk2, buildRubyGem
25, cairo, re2, rake, gobjectIntrospection, gdk_pixbuf, zeromq, graphicsmagick, libcxx
26}@args:
27
28let
29 v8 = v8_3_16_14;
30
31 rainbow_rake = buildRubyGem {
32 name = "rake";
33 gemName = "rake";
34 source.sha256 = "01j8fc9bqjnrsxbppncai05h43315vmz9fwg28qdsgcjw9ck1d7n";
35 type = "gem";
36 version = "12.0.0";
37 };
38in
39
40{
41 atk = attrs: {
42 nativeBuildInputs = [ pkgconfig ];
43 buildInputs = [ gtk2 pcre rake ];
44 };
45
46 bundler = attrs:
47 let
48 templates = "${attrs.ruby.gemPath}/gems/${attrs.gemName}-${attrs.version}/lib/bundler/templates/";
49 in {
50 # patching shebangs would fail on the templates/Executable file, so we
51 # temporarily remove the executable flag.
52 preFixup = "chmod -x $out/${templates}/Executable";
53 postFixup = ''
54 chmod +x $out/${templates}/Executable
55
56 # Allows to load another bundler version
57 sed -i -e "s/activate_bin_path/bin_path/g" $out/bin/bundle
58 '';
59 };
60
61 cairo = attrs: {
62 nativeBuildInputs = [ pkgconfig ];
63 buildInputs = [ gtk2 pcre xorg.libpthreadstubs xorg.libXdmcp];
64 };
65
66 cairo-gobject = attrs: {
67 nativeBuildInputs = [ pkgconfig ];
68 buildInputs = [ cairo pcre xorg.libpthreadstubs xorg.libXdmcp ];
69 };
70
71 capybara-webkit = attrs: {
72 buildInputs = [ qt48 ] ++ stdenv.lib.optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.Cocoa ];
73 NIX_CFLAGS_COMPILE = stdenv.lib.optionalString stdenv.isDarwin "-I${libcxx}/include/c++/v1";
74 };
75
76 charlock_holmes = attrs: {
77 buildInputs = [ which icu zlib ];
78 };
79
80 curb = attrs: {
81 buildInputs = [ curl ];
82 };
83
84 curses = attrs: {
85 buildInputs = [ ncurses ];
86 };
87
88 dep-selector-libgecode = attrs: {
89 USE_SYSTEM_GECODE = true;
90 postInstall = ''
91 installPath=$(cat $out/nix-support/gem-meta/install-path)
92 sed -i $installPath/lib/dep-selector-libgecode.rb -e 's@VENDORED_GECODE_DIR =.*@VENDORED_GECODE_DIR = "${gecode_3}"@'
93 '';
94 };
95
96 ethon = attrs: {
97 dontBuild = false;
98 postPatch = ''
99 substituteInPlace lib/ethon/curls/settings.rb \
100 --replace "libcurl" "${curl.out}/lib/libcurl${stdenv.hostPlatform.extensions.sharedLibrary}"
101 '';
102 };
103
104 fog-dnsimple = attrs: {
105 postInstall = ''
106 cd $(cat $out/nix-support/gem-meta/install-path)
107 rm {$out/bin,bin,../../bin}/{setup,console}
108 '';
109 };
110
111 redis-rack = attrs: {
112 dontBuild = false;
113 preBuild = ''
114 exec 3>&1
115 output="$(gem build $gemspec | tee >(cat - >&3))"
116 exec 3>&-
117 sed -i 's!"rake".freeze!!' $gemspec
118 '';
119 };
120
121 ffi-rzmq-core = attrs: {
122 postInstall = ''
123 installPath=$(cat $out/nix-support/gem-meta/install-path)
124 sed -i $installPath/lib/ffi-rzmq-core/libzmq.rb -e 's@inside_gem =.*@inside_gem = "${zeromq}/lib"@'
125 '';
126 };
127
128 mini_magick = attrs: {
129 postInstall = ''
130 installPath=$(cat $out/nix-support/gem-meta/install-path)
131 echo -e "\nENV['PATH'] += ':${graphicsmagick}/bin'\n" >> $installPath/lib/mini_magick/configuration.rb
132 '';
133 };
134
135 do_sqlite3 = attrs: {
136 buildInputs = [ sqlite ];
137 };
138
139 eventmachine = attrs: {
140 buildInputs = [ openssl ];
141 };
142
143 ffi = attrs: {
144 nativeBuildInputs = [ pkgconfig ];
145 buildInputs = [ libffi ];
146 };
147
148 gdk_pixbuf2 = attrs: {
149 nativeBuildInputs = [ pkgconfig ];
150 buildInputs = [ rake gdk_pixbuf ];
151 };
152
153 gpgme = attrs: {
154 buildInputs = [ gpgme ];
155 };
156
157 gio2 = attrs: {
158 nativeBuildInputs = [ pkgconfig ];
159 buildInputs = [ gtk2 pcre gobjectIntrospection ];
160 };
161
162 gitlab-markup = attrs: { meta.priority = 1; };
163
164 glib2 = attrs: {
165 nativeBuildInputs = [ pkgconfig ];
166 buildInputs = [ gtk2 pcre ];
167 };
168
169 gtk2 = attrs: {
170 nativeBuildInputs = [ pkgconfig ];
171 buildInputs = [ gtk2 pcre xorg.libpthreadstubs xorg.libXdmcp];
172 # CFLAGS must be set for this gem to detect gdkkeysyms.h correctly
173 CFLAGS = "-I${gtk2.dev}/include/gtk-2.0 -I/non-existent-path";
174 };
175
176 gobject-introspection = attrs: {
177 nativeBuildInputs = [ pkgconfig ];
178 buildInputs = [ gobjectIntrospection gtk2 pcre ];
179 };
180
181 grpc = attrs: {
182 nativeBuildInputs = [ pkgconfig ];
183 buildInputs = [ openssl ];
184 hardeningDisable = [ "format" ];
185 NIX_CFLAGS_COMPILE = [ "-Wno-error=stringop-overflow" "-Wno-error=implicit-fallthrough" ];
186 };
187
188 hitimes = attrs: {
189 buildInputs =
190 stdenv.lib.optionals stdenv.isDarwin
191 [ darwin.apple_sdk.frameworks.CoreServices ];
192 };
193
194 # disable bundle install as it can't install anything in addition to what is
195 # specified in pkgs/applications/misc/jekyll/Gemfile anyway. Also do chmod_R
196 # to compensate for read-only files in site_template in nix store.
197 jekyll = attrs: {
198 postInstall = ''
199 installPath=$(cat $out/nix-support/gem-meta/install-path)
200 sed -i $installPath/lib/jekyll/commands/new.rb \
201 -e 's@Exec.run("bundle", "install"@Exec.run("true"@' \
202 -e 's@FileUtils.cp_r site_template + "/.", path@FileUtils.cp_r site_template + "/.", path; FileUtils.chmod_R "u+w", path@'
203 '';
204 };
205
206 # note that you need version >= v3.16.14.8,
207 # otherwise the gem will fail to link to the libv8 binary.
208 # see: https://github.com/cowboyd/libv8/pull/161
209 libv8 = attrs: {
210 buildInputs = [ which v8 python ];
211 buildFlags = [ "--with-system-v8=true" ];
212 };
213
214 libxml-ruby = attrs: {
215 buildFlags = [
216 "--with-xml2-lib=${libxml2.out}/lib"
217 "--with-xml2-include=${libxml2.dev}/include/libxml2"
218 ];
219 };
220
221 msgpack = attrs: {
222 buildInputs = [ msgpack ];
223 };
224
225 mysql = attrs: {
226 buildInputs = [ mysql.connector-c zlib openssl ];
227 };
228
229 mysql2 = attrs: {
230 buildInputs = [ mysql.connector-c zlib openssl ];
231 };
232
233 ncursesw = attrs: {
234 buildInputs = [ ncurses ];
235 buildFlags = [
236 "--with-cflags=-I${ncurses.dev}/include"
237 "--with-ldflags=-L${ncurses.out}/lib"
238 ];
239 };
240
241 nokogiri = attrs: {
242 buildFlags = [
243 "--use-system-libraries"
244 "--with-zlib-dir=${zlib.dev}"
245 "--with-xml2-lib=${libxml2.out}/lib"
246 "--with-xml2-include=${libxml2.dev}/include/libxml2"
247 "--with-xslt-lib=${libxslt.out}/lib"
248 "--with-xslt-include=${libxslt.dev}/include"
249 "--with-exslt-lib=${libxslt.out}/lib"
250 "--with-exslt-include=${libxslt.dev}/include"
251 ] ++ lib.optional stdenv.isDarwin "--with-iconv-dir=${libiconv}";
252 };
253
254 oxidized = attrs: {
255 postInstall = ''
256 cd "$(cat "$out/nix-support/gem-meta/install-path")"
257 patch -p1 < ${../../../tools/admin/oxidized/temporary-x-series.patch}
258 '';
259 };
260
261 pango = attrs: {
262 nativeBuildInputs = [ pkgconfig ];
263 buildInputs = [ gtk2 xorg.libXdmcp pcre xorg.libpthreadstubs ];
264 };
265
266 patron = attrs: {
267 buildInputs = [ curl ];
268 };
269
270 pcaprub = attrs: {
271 buildInputs = [ libpcap ];
272 };
273
274 pg = attrs: {
275 buildFlags = [
276 "--with-pg-config=${postgresql}/bin/pg_config"
277 ];
278 };
279
280 puma = attrs: {
281 buildInputs = [ openssl ];
282 };
283
284 rainbow = attrs: {
285 buildInputs = [ rainbow_rake ];
286 };
287
288 rbnacl = spec: {
289 postInstall = ''
290 sed -i $(cat $out/nix-support/gem-meta/install-path)/lib/rbnacl.rb -e "2a \
291 RBNACL_LIBSODIUM_GEM_LIB_PATH = '${libsodium.out}/lib/libsodium${stdenv.hostPlatform.extensions.sharedLibrary}'
292 "
293 '';
294 };
295
296 re2 = attrs: {
297 buildInputs = [ re2 ];
298 };
299
300 rmagick = attrs: {
301 nativeBuildInputs = [ pkgconfig ];
302 buildInputs = [ imagemagick which ];
303 };
304
305 ruby-lxc = attrs: {
306 buildInputs = [ lxc ];
307 };
308
309 ruby-terminfo = attrs: {
310 buildInputs = [ ncurses ];
311 buildFlags = [
312 "--with-cflags=-I${ncurses.dev}/include"
313 "--with-ldflags=-L${ncurses.out}/lib"
314 ];
315 };
316 rugged = attrs: {
317 nativeBuildInputs = [ pkgconfig ];
318 buildInputs = [ cmake openssl libssh2 zlib ];
319 dontUseCmakeConfigure = true;
320 };
321
322 scrypt = attrs:
323 if stdenv.isDarwin then {
324 dontBuild = false;
325 postPatch = ''
326 sed -i -e "s/-arch i386//" Rakefile ext/scrypt/Rakefile
327 '';
328 } else {};
329
330 sequel_pg = attrs: {
331 buildInputs = [ postgresql ];
332 };
333
334 snappy = attrs: {
335 buildInputs = [ args.snappy ];
336 };
337
338 sqlite3 = attrs: {
339 buildFlags = [
340 "--with-sqlite3-include=${sqlite.dev}/include"
341 "--with-sqlite3-lib=${sqlite.out}/lib"
342 ];
343 };
344
345 sup = attrs: {
346 dontBuild = false;
347 # prevent sup from trying to dynamically install `xapian-ruby`.
348 postPatch = ''
349 cp ${./mkrf_conf_xapian.rb} ext/mkrf_conf_xapian.rb
350
351 substituteInPlace lib/sup/crypto.rb \
352 --replace 'which gpg2' \
353 '${which}/bin/which gpg'
354 '';
355 };
356
357 rb-readline = attrs: {
358 dontBuild = false;
359 postPatch = ''
360 substituteInPlace lib/rbreadline.rb \
361 --replace 'infocmp' '${ncurses.dev}/bin/infocmp'
362 '';
363 };
364
365 timfel-krb5-auth = attrs: {
366 buildInputs = [ kerberos ];
367 };
368
369 tiny_tds = attrs: {
370 nativeBuildInputs = [ pkgconfig openssl ];
371 };
372
373 therubyracer = attrs: {
374 buildFlags = [
375 "--with-v8-dir=${v8}"
376 "--with-v8-include=${v8}/include"
377 "--with-v8-lib=${v8}/lib"
378 ];
379 };
380
381 typhoeus = attrs: {
382 buildInputs = [ curl ];
383 };
384
385 tzinfo = attrs: lib.optionalAttrs (lib.versionAtLeast attrs.version "1.0") {
386 dontBuild = false;
387 postPatch = ''
388 substituteInPlace lib/tzinfo/zoneinfo_data_source.rb \
389 --replace "/usr/share/zoneinfo" "${tzdata}/share/zoneinfo"
390 '';
391 };
392
393 uuid4r = attrs: {
394 buildInputs = [ which libossp_uuid ];
395 };
396
397 xapian-ruby = attrs: {
398 # use the system xapian
399 dontBuild = false;
400 nativeBuildInputs = [ pkgconfig ];
401 buildInputs = [ xapian_1_2_22 zlib ];
402 postPatch = ''
403 cp ${./xapian-Rakefile} Rakefile
404 '';
405 preInstall = ''
406 export XAPIAN_CONFIG=${xapian_1_2_22}/bin/xapian-config
407 '';
408 };
409
410 zookeeper = attrs: {
411 buildInputs = stdenv.lib.optionals stdenv.isDarwin [ darwin.cctools ];
412 };
413
414}