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}@args:
26
27let
28 v8 = v8_3_16_14;
29
30 rainbow_rake = buildRubyGem {
31 name = "rake";
32 gemName = "rake";
33 remotes = ["https://rubygems.org"];
34 sha256 = "01j8fc9bqjnrsxbppncai05h43315vmz9fwg28qdsgcjw9ck1d7n";
35 type = "gem";
36 version = "12.0.0";
37 };
38in
39
40{
41 atk = attrs: { buildInputs = [ gtk2 pcre pkgconfig ]; };
42
43 bundler = attrs:
44 let
45 templates = "${attrs.ruby.gemPath}/gems/${attrs.gemName}-${attrs.version}/lib/bundler/templates/";
46 in {
47 # patching shebangs would fail on the templates/Executable file, so we
48 # temporarily remove the executable flag.
49 preFixup = "chmod -x $out/${templates}/Executable";
50 postFixup = ''
51 chmod +x $out/${templates}/Executable
52
53 # Allows to load another bundler version
54 sed -i -e "s/activate_bin_path/bin_path/g" $out/bin/bundle
55 '';
56 };
57
58 cairo = attrs: {
59 buildInputs = [ gtk2 pcre pkgconfig xlibs.libpthreadstubs xlibs.libXdmcp];
60 };
61
62 capybara-webkit = attrs: {
63 buildInputs = [ qt48 ];
64 };
65
66 charlock_holmes = attrs: {
67 buildInputs = [ which icu zlib ];
68 };
69
70 dep-selector-libgecode = attrs: {
71 USE_SYSTEM_GECODE = true;
72 postInstall = ''
73 installPath=$(cat $out/nix-support/gem-meta/install-path)
74 sed -i $installPath/lib/dep-selector-libgecode.rb -e 's@VENDORED_GECODE_DIR =.*@VENDORED_GECODE_DIR = "${gecode_3}"@'
75 '';
76 };
77
78 eventmachine = attrs: {
79 buildInputs = [ openssl ];
80 };
81
82 ffi = attrs: {
83 buildInputs = [ libffi pkgconfig ];
84 };
85
86 gpgme = attrs: {
87 buildInputs = [ gpgme ];
88 };
89
90 gio2 = attrs: { buildInputs = [ gtk2 pcre pkgconfig ]; };
91
92 glib2 = attrs: { buildInputs = [ gtk2 pcre pkgconfig ]; };
93
94 gtk2 = attrs: {
95 buildInputs = [ gtk2 pcre pkgconfig xlibs.libpthreadstubs xlibs.libXdmcp];
96 # CFLAGS must be set for this gem to detect gdkkeysyms.h correctly
97 CFLAGS = "-I${gtk2.dev}/include/gtk-2.0 -I/non-existent-path";
98 };
99
100 gobject-introspection = attrs: { buildInputs = [ gtk2 pcre pkgconfig ]; };
101
102 hitimes = attrs: {
103 buildInputs =
104 stdenv.lib.optionals stdenv.isDarwin
105 [ darwin.apple_sdk.frameworks.CoreServices ];
106 };
107
108 # disable bundle install as it can't install anything in addition to what is
109 # specified in pkgs/applications/misc/jekyll/Gemfile anyway. Also do chmod_R
110 # to compensate for read-only files in site_template in nix store.
111 jekyll = attrs: {
112 postInstall = ''
113 installPath=$(cat $out/nix-support/gem-meta/install-path)
114 sed -i $installPath/lib/jekyll/commands/new.rb \
115 -e 's@Exec.run("bundle", "install"@Exec.run("true"@' \
116 -e 's@FileUtils.cp_r site_template + "/.", path@FileUtils.cp_r site_template + "/.", path; FileUtils.chmod_R "u+w", path@'
117 '';
118 };
119
120 # note that you need version >= v3.16.14.8,
121 # otherwise the gem will fail to link to the libv8 binary.
122 # see: https://github.com/cowboyd/libv8/pull/161
123 libv8 = attrs: {
124 buildInputs = [ which v8 python ];
125 buildFlags = [ "--with-system-v8=true" ];
126 };
127
128 msgpack = attrs: {
129 buildInputs = [ libmsgpack ];
130 };
131
132 mysql = attrs: {
133 buildInputs = [ mysql.lib zlib openssl ];
134 };
135
136 mysql2 = attrs: {
137 buildInputs = [ mysql.lib zlib openssl ];
138 };
139
140 ncursesw = attrs: {
141 buildInputs = [ ncurses ];
142 buildFlags = [
143 "--with-cflags=-I${ncurses.dev}/include"
144 "--with-ldflags=-L${ncurses.out}/lib"
145 ];
146 };
147
148 nokogiri = attrs: {
149 buildFlags = [
150 "--use-system-libraries"
151 "--with-zlib-dir=${zlib.dev}"
152 "--with-xml2-lib=${libxml2.out}/lib"
153 "--with-xml2-include=${libxml2.dev}/include/libxml2"
154 "--with-xslt-lib=${libxslt.out}/lib"
155 "--with-xslt-include=${libxslt.dev}/include"
156 "--with-exslt-lib=${libxslt.out}/lib"
157 "--with-exslt-include=${libxslt.dev}/include"
158 ] ++ lib.optional stdenv.isDarwin "--with-iconv-dir=${libiconv}";
159 };
160
161 pango = attrs: {
162 buildInputs = [ gtk2 xlibs.libXdmcp pcre pkgconfig xlibs.libpthreadstubs ];
163 };
164
165 patron = attrs: {
166 buildInputs = [ curl ];
167 };
168
169 pcaprub = attrs: {
170 buildInputs = [ libpcap ];
171 };
172
173 pg = attrs: {
174 buildFlags = [
175 "--with-pg-config=${postgresql}/bin/pg_config"
176 ];
177 };
178
179 puma = attrs: {
180 buildInputs = [ openssl ];
181 };
182
183 rainbow = attrs: {
184 buildInputs = [ rainbow_rake ];
185 };
186
187 rbnacl = spec: {
188 postInstall = ''
189 sed -i $(cat $out/nix-support/gem-meta/install-path)/lib/rbnacl.rb -e "2a \
190 RBNACL_LIBSODIUM_GEM_LIB_PATH = '${libsodium.out}/lib/libsodium.${if stdenv.isDarwin then "dylib" else "so"}'
191 "
192 '';
193 };
194
195 rmagick = attrs: {
196 buildInputs = [ imagemagick pkgconfig which ];
197 };
198
199 ruby-lxc = attrs: {
200 buildInputs = [ lxc ];
201 };
202
203 ruby-terminfo = attrs: {
204 buildInputs = [ ncurses ];
205 buildFlags = [
206 "--with-cflags=-I${ncurses.dev}/include"
207 "--with-ldflags=-L${ncurses.out}/lib"
208 ];
209 };
210 rugged = attrs: {
211 buildInputs = [ cmake pkgconfig openssl libssh2 zlib ];
212 };
213
214 scrypt = attrs:
215 if stdenv.isDarwin then {
216 dontBuild = false;
217 postPatch = ''
218 sed -i -e "s/-arch i386//" Rakefile ext/scrypt/Rakefile
219 '';
220 } else {};
221
222 sequel_pg = attrs: {
223 buildInputs = [ postgresql ];
224 };
225
226 snappy = attrs: {
227 buildInputs = [ args.snappy ];
228 };
229
230 sqlite3 = attrs: {
231 buildFlags = [
232 "--with-sqlite3-include=${sqlite.dev}/include"
233 "--with-sqlite3-lib=${sqlite.out}/lib"
234 ];
235 };
236
237 sup = attrs: {
238 dontBuild = false;
239 # prevent sup from trying to dynamically install `xapian-ruby`.
240 postPatch = ''
241 cp ${./mkrf_conf_xapian.rb} ext/mkrf_conf_xapian.rb
242
243 substituteInPlace lib/sup/crypto.rb \
244 --replace 'which gpg2' \
245 '${which}/bin/which gpg'
246 '';
247 };
248
249 rb-readline = attrs: {
250 dontBuild = false;
251 postPatch = ''
252 substituteInPlace lib/rbreadline.rb \
253 --replace 'infocmp' '${ncurses.dev}/bin/infocmp'
254 '';
255 };
256
257 timfel-krb5-auth = attrs: {
258 buildInputs = [ kerberos ];
259 };
260
261 therubyracer = attrs: {
262 buildFlags = [
263 "--with-v8-dir=${v8}"
264 "--with-v8-include=${v8}/include"
265 "--with-v8-lib=${v8}/lib"
266 ];
267 };
268
269 typhoeus = attrs: {
270 buildInputs = [ curl ];
271 };
272
273 tzinfo = attrs: lib.optionalAttrs (lib.versionAtLeast attrs.version "1.0") {
274 dontBuild = false;
275 postPatch = ''
276 substituteInPlace lib/tzinfo/zoneinfo_data_source.rb \
277 --replace "/usr/share/zoneinfo" "${tzdata}/share/zoneinfo"
278 '';
279 };
280
281 uuid4r = attrs: {
282 buildInputs = [ which libossp_uuid ];
283 };
284
285 xapian-ruby = attrs: {
286 # use the system xapian
287 dontBuild = false;
288 buildInputs = [ xapian_1_2_22 pkgconfig zlib ];
289 postPatch = ''
290 cp ${./xapian-Rakefile} Rakefile
291 '';
292 preInstall = ''
293 export XAPIAN_CONFIG=${xapian_1_2_22}/bin/xapian-config
294 '';
295 };
296
297}