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, libmsgpack, qt48, libsodium, snappy, libossp_uuid, lxc, libpcap, xlibs, gtk2, buildRubyGem
25, cairo, re2, rake, gobjectIntrospection, gdk_pixbuf
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 xlibs.libpthreadstubs xlibs.libXdmcp];
64 };
65
66 cairo-gobject = attrs: {
67 nativeBuildInputs = [ pkgconfig ];
68 buildInputs = [ cairo pcre xlibs.libpthreadstubs xlibs.libXdmcp ];
69 };
70
71 capybara-webkit = attrs: {
72 buildInputs = [ qt48 ];
73 };
74
75 charlock_holmes = attrs: {
76 buildInputs = [ which icu zlib ];
77 };
78
79 curb = attrs: {
80 buildInputs = [ curl ];
81 };
82
83 dep-selector-libgecode = attrs: {
84 USE_SYSTEM_GECODE = true;
85 postInstall = ''
86 installPath=$(cat $out/nix-support/gem-meta/install-path)
87 sed -i $installPath/lib/dep-selector-libgecode.rb -e 's@VENDORED_GECODE_DIR =.*@VENDORED_GECODE_DIR = "${gecode_3}"@'
88 '';
89 };
90
91 ethon = attrs: {
92 dontBuild = false;
93 postPatch = ''
94 substituteInPlace lib/ethon/curls/settings.rb \
95 --replace "libcurl" "${curl.out}/lib/libcurl${stdenv.hostPlatform.extensions.sharedLibrary}"
96 '';
97 };
98
99 eventmachine = attrs: {
100 buildInputs = [ openssl ];
101 };
102
103 ffi = attrs: {
104 nativeBuildInputs = [ pkgconfig ];
105 buildInputs = [ libffi ];
106 };
107
108 gdk_pixbuf2 = attrs: {
109 nativeBuildInputs = [ pkgconfig ];
110 buildInputs = [ rake gdk_pixbuf ];
111 };
112
113 gpgme = attrs: {
114 buildInputs = [ gpgme ];
115 };
116
117 gio2 = attrs: {
118 nativeBuildInputs = [ pkgconfig ];
119 buildInputs = [ gtk2 pcre gobjectIntrospection ];
120 };
121
122 gitlab-markup = attrs: { meta.priority = 1; };
123
124 glib2 = attrs: {
125 nativeBuildInputs = [ pkgconfig ];
126 buildInputs = [ gtk2 pcre ];
127 };
128
129 gtk2 = attrs: {
130 nativeBuildInputs = [ pkgconfig ];
131 buildInputs = [ gtk2 pcre xlibs.libpthreadstubs xlibs.libXdmcp];
132 # CFLAGS must be set for this gem to detect gdkkeysyms.h correctly
133 CFLAGS = "-I${gtk2.dev}/include/gtk-2.0 -I/non-existent-path";
134 };
135
136 gobject-introspection = attrs: {
137 nativeBuildInputs = [ pkgconfig ];
138 buildInputs = [ gobjectIntrospection gtk2 pcre ];
139 };
140
141 grpc = attrs: {
142 nativeBuildInputs = [ pkgconfig ];
143 buildInputs = [ openssl ];
144 hardeningDisable = [ "format" ];
145 NIX_CFLAGS_COMPILE = [ "-Wno-error=stringop-overflow" "-Wno-error=implicit-fallthrough" ];
146 };
147
148 hitimes = attrs: {
149 buildInputs =
150 stdenv.lib.optionals stdenv.isDarwin
151 [ darwin.apple_sdk.frameworks.CoreServices ];
152 };
153
154 # disable bundle install as it can't install anything in addition to what is
155 # specified in pkgs/applications/misc/jekyll/Gemfile anyway. Also do chmod_R
156 # to compensate for read-only files in site_template in nix store.
157 jekyll = attrs: {
158 postInstall = ''
159 installPath=$(cat $out/nix-support/gem-meta/install-path)
160 sed -i $installPath/lib/jekyll/commands/new.rb \
161 -e 's@Exec.run("bundle", "install"@Exec.run("true"@' \
162 -e 's@FileUtils.cp_r site_template + "/.", path@FileUtils.cp_r site_template + "/.", path; FileUtils.chmod_R "u+w", path@'
163 '';
164 };
165
166 # note that you need version >= v3.16.14.8,
167 # otherwise the gem will fail to link to the libv8 binary.
168 # see: https://github.com/cowboyd/libv8/pull/161
169 libv8 = attrs: {
170 buildInputs = [ which v8 python ];
171 buildFlags = [ "--with-system-v8=true" ];
172 };
173
174 msgpack = attrs: {
175 buildInputs = [ libmsgpack ];
176 };
177
178 mysql = attrs: {
179 buildInputs = [ mysql.connector-c zlib openssl ];
180 };
181
182 mysql2 = attrs: {
183 buildInputs = [ mysql.connector-c zlib openssl ];
184 };
185
186 ncursesw = attrs: {
187 buildInputs = [ ncurses ];
188 buildFlags = [
189 "--with-cflags=-I${ncurses.dev}/include"
190 "--with-ldflags=-L${ncurses.out}/lib"
191 ];
192 };
193
194 nokogiri = attrs: {
195 buildFlags = [
196 "--use-system-libraries"
197 "--with-zlib-dir=${zlib.dev}"
198 "--with-xml2-lib=${libxml2.out}/lib"
199 "--with-xml2-include=${libxml2.dev}/include/libxml2"
200 "--with-xslt-lib=${libxslt.out}/lib"
201 "--with-xslt-include=${libxslt.dev}/include"
202 "--with-exslt-lib=${libxslt.out}/lib"
203 "--with-exslt-include=${libxslt.dev}/include"
204 ] ++ lib.optional stdenv.isDarwin "--with-iconv-dir=${libiconv}";
205 };
206
207 pango = attrs: {
208 nativeBuildInputs = [ pkgconfig ];
209 buildInputs = [ gtk2 xlibs.libXdmcp pcre xlibs.libpthreadstubs ];
210 };
211
212 patron = attrs: {
213 buildInputs = [ curl ];
214 };
215
216 pcaprub = attrs: {
217 buildInputs = [ libpcap ];
218 };
219
220 pg = attrs: {
221 buildFlags = [
222 "--with-pg-config=${postgresql}/bin/pg_config"
223 ];
224 };
225
226 puma = attrs: {
227 buildInputs = [ openssl ];
228 };
229
230 rainbow = attrs: {
231 buildInputs = [ rainbow_rake ];
232 };
233
234 rbnacl = spec: {
235 postInstall = ''
236 sed -i $(cat $out/nix-support/gem-meta/install-path)/lib/rbnacl.rb -e "2a \
237 RBNACL_LIBSODIUM_GEM_LIB_PATH = '${libsodium.out}/lib/libsodium${stdenv.hostPlatform.extensions.sharedLibrary}'
238 "
239 '';
240 };
241
242 re2 = attrs: {
243 buildInputs = [ re2 ];
244 };
245
246 rmagick = attrs: {
247 nativeBuildInputs = [ pkgconfig ];
248 buildInputs = [ imagemagick which ];
249 };
250
251 ruby-lxc = attrs: {
252 buildInputs = [ lxc ];
253 };
254
255 ruby-terminfo = attrs: {
256 buildInputs = [ ncurses ];
257 buildFlags = [
258 "--with-cflags=-I${ncurses.dev}/include"
259 "--with-ldflags=-L${ncurses.out}/lib"
260 ];
261 };
262 rugged = attrs: {
263 nativeBuildInputs = [ pkgconfig ];
264 buildInputs = [ cmake openssl libssh2 zlib ];
265 dontUseCmakeConfigure = true;
266 };
267
268 scrypt = attrs:
269 if stdenv.isDarwin then {
270 dontBuild = false;
271 postPatch = ''
272 sed -i -e "s/-arch i386//" Rakefile ext/scrypt/Rakefile
273 '';
274 } else {};
275
276 sequel_pg = attrs: {
277 buildInputs = [ postgresql ];
278 };
279
280 snappy = attrs: {
281 buildInputs = [ args.snappy ];
282 };
283
284 sqlite3 = attrs: {
285 buildFlags = [
286 "--with-sqlite3-include=${sqlite.dev}/include"
287 "--with-sqlite3-lib=${sqlite.out}/lib"
288 ];
289 };
290
291 sup = attrs: {
292 dontBuild = false;
293 # prevent sup from trying to dynamically install `xapian-ruby`.
294 postPatch = ''
295 cp ${./mkrf_conf_xapian.rb} ext/mkrf_conf_xapian.rb
296
297 substituteInPlace lib/sup/crypto.rb \
298 --replace 'which gpg2' \
299 '${which}/bin/which gpg'
300 '';
301 };
302
303 rb-readline = attrs: {
304 dontBuild = false;
305 postPatch = ''
306 substituteInPlace lib/rbreadline.rb \
307 --replace 'infocmp' '${ncurses.dev}/bin/infocmp'
308 '';
309 };
310
311 timfel-krb5-auth = attrs: {
312 buildInputs = [ kerberos ];
313 };
314
315 therubyracer = attrs: {
316 buildFlags = [
317 "--with-v8-dir=${v8}"
318 "--with-v8-include=${v8}/include"
319 "--with-v8-lib=${v8}/lib"
320 ];
321 };
322
323 typhoeus = attrs: {
324 buildInputs = [ curl ];
325 };
326
327 tzinfo = attrs: lib.optionalAttrs (lib.versionAtLeast attrs.version "1.0") {
328 dontBuild = false;
329 postPatch = ''
330 substituteInPlace lib/tzinfo/zoneinfo_data_source.rb \
331 --replace "/usr/share/zoneinfo" "${tzdata}/share/zoneinfo"
332 '';
333 };
334
335 uuid4r = attrs: {
336 buildInputs = [ which libossp_uuid ];
337 };
338
339 xapian-ruby = attrs: {
340 # use the system xapian
341 dontBuild = false;
342 nativeBuildInputs = [ pkgconfig ];
343 buildInputs = [ xapian_1_2_22 zlib ];
344 postPatch = ''
345 cp ${./xapian-Rakefile} Rakefile
346 '';
347 preInstall = ''
348 export XAPIAN_CONFIG=${xapian_1_2_22}/bin/xapian-config
349 '';
350 };
351
352}