diff --git a/doc/language-support.xml b/doc/language-support.xml
index 4446e9ee382..7d016ae6fb9 100644
--- a/doc/language-support.xml
+++ b/doc/language-support.xml
@@ -618,7 +618,7 @@ sed -i '/ = data_files/d' setup.py
$ nix-env -i gem-nix
$ gem-nix --no-user-install --nix-file=pkgs/development/interpreters/ruby/generated.nix yajl-ruby
- $ nix-build -A rubyLibs.yajl-ruby
+ $ nix-build -A rubyPackages.yajl-ruby
diff --git a/nixos/modules/services/misc/redmine.nix b/nixos/modules/services/misc/redmine.nix
index d7e64590f50..059cc18733b 100644
--- a/nixos/modules/services/misc/redmine.nix
+++ b/nixos/modules/services/misc/redmine.nix
@@ -8,7 +8,6 @@ let
cfg = config.services.redmine;
ruby = pkgs.ruby;
- rubyLibs = pkgs.rubyLibs;
databaseYml = ''
production:
@@ -155,7 +154,7 @@ in {
environment.HOME = "${pkgs.redmine}/share/redmine";
environment.REDMINE_LANG = "en";
environment.GEM_HOME = "${pkgs.redmine}/share/redmine/vendor/bundle/ruby/1.9.1";
- environment.GEM_PATH = "${rubyLibs.bundler}/lib/ruby/gems/1.9";
+ environment.GEM_PATH = "${bundler}/${bundler.ruby.gemPath}";
path = with pkgs; [
imagemagickBig
subversion
diff --git a/nixos/modules/services/monitoring/riemann-dash.nix b/nixos/modules/services/monitoring/riemann-dash.nix
index 148dc046805..523f74cb72b 100644
--- a/nixos/modules/services/monitoring/riemann-dash.nix
+++ b/nixos/modules/services/monitoring/riemann-dash.nix
@@ -15,7 +15,7 @@ let
launcher = writeScriptBin "riemann-dash" ''
#!/bin/sh
- exec ${rubyLibs.riemann_dash}/bin/riemann-dash ${conf}
+ exec ${pkgs.riemann-dash}/bin/riemann-dash ${conf}
'';
in {
diff --git a/pkgs/applications/networking/mailreaders/sup/.bundix/cache b/pkgs/applications/networking/mailreaders/sup/.bundix/cache
new file mode 100644
index 00000000000..5894e96022c
--- /dev/null
+++ b/pkgs/applications/networking/mailreaders/sup/.bundix/cache
@@ -0,0 +1,4 @@
+---
+gem:
+ https://rubygems.org/downloads/mini_portile-0.6.0.gem: 09kcn4g63xrdirgwxgjikqg976rr723bkc9bxfr29pk22cj3wavn
+ https://rubygems.org/downloads/gpgme-2.0.7.gem: 1p84zhiri2ihcld7py9mwc2kg5xs5da8fk11zhndrhmw05yvf5mr
diff --git a/pkgs/applications/networking/mailreaders/sup/Gemfile b/pkgs/applications/networking/mailreaders/sup/Gemfile
new file mode 100644
index 00000000000..a57feb5d21f
--- /dev/null
+++ b/pkgs/applications/networking/mailreaders/sup/Gemfile
@@ -0,0 +1,8 @@
+source "https://rubygems.org"
+
+gem 'sup'
+gem 'gpgme'
+
+# Sup tries to `xapian-ruby` in its extconf instead of listing it as a
+# dependency.
+gem 'xapian-ruby', "~> 1.2.15"
diff --git a/pkgs/applications/networking/mailreaders/sup/Gemfile.lock b/pkgs/applications/networking/mailreaders/sup/Gemfile.lock
new file mode 100644
index 00000000000..fe8746b9f72
--- /dev/null
+++ b/pkgs/applications/networking/mailreaders/sup/Gemfile.lock
@@ -0,0 +1,34 @@
+GEM
+ remote: https://rubygems.org/
+ specs:
+ chronic (0.9.1)
+ gpgme (2.0.7)
+ mini_portile (>= 0.5.0, <= 0.6.0)
+ highline (1.6.21)
+ locale (2.1.0)
+ lockfile (2.1.3)
+ mime-types (1.25.1)
+ mini_portile (0.6.0)
+ ncursesw (1.4.9)
+ rmail-sup (1.0.1)
+ sup (0.20.0)
+ chronic (~> 0.9.1)
+ highline
+ locale (~> 2.0)
+ lockfile
+ mime-types (~> 1.0)
+ ncursesw (~> 1.4.0)
+ rmail-sup (~> 1.0.1)
+ trollop (>= 1.12)
+ unicode (~> 0.4.4)
+ trollop (2.1.1)
+ unicode (0.4.4.2)
+ xapian-ruby (1.2.19.1)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ gpgme
+ sup
+ xapian-ruby (~> 1.2.15)
diff --git a/pkgs/applications/networking/mailreaders/sup/default.nix b/pkgs/applications/networking/mailreaders/sup/default.nix
index 3d537d83f43..19715d7b255 100644
--- a/pkgs/applications/networking/mailreaders/sup/default.nix
+++ b/pkgs/applications/networking/mailreaders/sup/default.nix
@@ -1,79 +1,19 @@
-{ stdenv, fetchurl, ruby, rake, rubygems, makeWrapper, ncursesw_sup
-, xapian_ruby, gpgme, libiconvOrEmpty, mime_types, chronic, trollop, lockfile
-, gettext, iconv, locale, text, highline, rmail_sup, unicode, gnupg, which
-, bundler, git }:
+{ stdenv, lib, bundlerEnv, gpgme, ruby, ncurses, writeText, zlib, xapian
+, pkgconfig, which }:
-stdenv.mkDerivation rec {
- version = "0.18.0";
- name = "sup-${version}";
+bundlerEnv {
+ name = "sup-0.20.0";
- meta = {
+ inherit ruby;
+ gemfile = ./Gemfile;
+ lockfile = ./Gemfile.lock;
+ gemset = ./gemset.nix;
+
+ meta = with lib; {
description = "A curses threads-with-tags style email client";
homepage = http://supmua.org;
- license = stdenv.lib.licenses.gpl2;
- maintainers = with stdenv.lib.maintainers; [ lovek323 ];
- platforms = stdenv.lib.platforms.unix;
- broken = true;
+ license = with licenses; gpl2;
+ maintainers = with maintainers; [ cstrahan lovek323 ];
+ platforms = platforms.unix;
};
-
- dontStrip = true;
-
- src = fetchurl {
- url = "https://github.com/sup-heliotrope/sup/archive/release-${version}.tar.gz";
- sha256 = "1dhg0i2v0ddhwi32ih5lc56x00kbaikd2wdplgzlshq0nljr9xy0";
- };
-
- buildInputs =
- [ rake ruby rubygems makeWrapper gpgme ncursesw_sup xapian_ruby
- libiconvOrEmpty git ];
-
- phases = [ "unpackPhase" "buildPhase" "installPhase" ];
-
- buildPhase = ''
- # the builder uses git to get a listing of the files
- export EMAIL="nobody@in.here"
- git init >/dev/null
- git add .
- git commit -m "message" >/dev/null
- gem build sup.gemspec
- '';
-
- installPhase = ''
- export HOME=$TMP/home; mkdir -pv "$HOME"
-
- GEM_PATH="$GEM_PATH:$out/${ruby.gemPath}"
- GEM_PATH="$GEM_PATH:${chronic}/${ruby.gemPath}"
- GEM_PATH="$GEM_PATH:${gettext}/${ruby.gemPath}"
- GEM_PATH="$GEM_PATH:${gpgme}/${ruby.gemPath}"
- GEM_PATH="$GEM_PATH:${highline}/${ruby.gemPath}"
- GEM_PATH="$GEM_PATH:${iconv}/${ruby.gemPath}"
- GEM_PATH="$GEM_PATH:${locale}/${ruby.gemPath}"
- GEM_PATH="$GEM_PATH:${lockfile}/${ruby.gemPath}"
- GEM_PATH="$GEM_PATH:${mime_types}/${ruby.gemPath}"
- GEM_PATH="$GEM_PATH:${ncursesw_sup}/${ruby.gemPath}"
- GEM_PATH="$GEM_PATH:${rmail_sup}/${ruby.gemPath}"
- GEM_PATH="$GEM_PATH:${text}/${ruby.gemPath}"
- GEM_PATH="$GEM_PATH:${trollop}/${ruby.gemPath}"
- GEM_PATH="$GEM_PATH:${unicode}/${ruby.gemPath}"
- GEM_PATH="$GEM_PATH:${xapian_ruby}/${ruby.gemPath}"
-
- # Don't install some dependencies -- we have already installed
- # the dependencies but gem doesn't acknowledge this
- gem install --no-verbose --install-dir "$out/${ruby.gemPath}" \
- --bindir "$out/bin" --no-rdoc --no-ri sup-${version}.gem \
- --ignore-dependencies >/dev/null
-
- # specify ruby interpreter explicitly
- sed -i '1 s|^.*$|#!${ruby}/bin/ruby|' bin/sup-sync-back-maildir
-
- cp bin/sup-sync-back-maildir "$out/bin"
-
- for prog in $out/bin/*; do
- wrapProgram "$prog" --prefix GEM_PATH : "$GEM_PATH" --prefix PATH : "${gnupg}/bin:${which}/bin"
- done
-
- for prog in $out/gems/*/bin/*; do
- [[ -e "$out/bin/$(basename $prog)" ]]
- done
- '';
}
diff --git a/pkgs/applications/networking/mailreaders/sup/gemset.nix b/pkgs/applications/networking/mailreaders/sup/gemset.nix
new file mode 100644
index 00000000000..e39da3dac85
--- /dev/null
+++ b/pkgs/applications/networking/mailreaders/sup/gemset.nix
@@ -0,0 +1,107 @@
+{
+ "chronic" = {
+ version = "0.9.1";
+ source = {
+ type = "gem";
+ sha256 = "0kspaxpfy7yvyk1lvpx31w852qfj8wb9z04mcj5bzi70ljb9awqk";
+ };
+ };
+ "gpgme" = {
+ version = "2.0.7";
+ source = {
+ type = "gem";
+ sha256 = "1p84zhiri2ihcld7py9mwc2kg5xs5da8fk11zhndrhmw05yvf5mr";
+ };
+ dependencies = [
+ "mini_portile"
+ ];
+ };
+ "highline" = {
+ version = "1.6.21";
+ source = {
+ type = "gem";
+ sha256 = "06bml1fjsnrhd956wqq5k3w8cyd09rv1vixdpa3zzkl6xs72jdn1";
+ };
+ };
+ "locale" = {
+ version = "2.1.0";
+ source = {
+ type = "gem";
+ sha256 = "18bb0g24flq9dr8qv4j7pm7w9i2vmvmqrbmry95ibf1r1c4s60yj";
+ };
+ };
+ "lockfile" = {
+ version = "2.1.3";
+ source = {
+ type = "gem";
+ sha256 = "0dij3ijywylvfgrpi2i0k17f6w0wjhnjjw0k9030f54z56cz7jrr";
+ };
+ };
+ "mime-types" = {
+ version = "1.25.1";
+ source = {
+ type = "gem";
+ sha256 = "0mhzsanmnzdshaba7gmsjwnv168r1yj8y0flzw88frw1cickrvw8";
+ };
+ };
+ "mini_portile" = {
+ version = "0.6.0";
+ source = {
+ type = "gem";
+ sha256 = "09kcn4g63xrdirgwxgjikqg976rr723bkc9bxfr29pk22cj3wavn";
+ };
+ };
+ "ncursesw" = {
+ version = "1.4.9";
+ source = {
+ type = "gem";
+ sha256 = "154cls3b237imdbhih7rni5p85nw6mpbpkzdw08jxzvqaml7q093";
+ };
+ };
+ "rmail-sup" = {
+ version = "1.0.1";
+ source = {
+ type = "gem";
+ sha256 = "1xswk101s560lxqaax3plqh8vjx7jjspnggdwb3q80m358f92q9g";
+ };
+ };
+ "sup" = {
+ version = "0.20.0";
+ source = {
+ type = "gem";
+ sha256 = "1lpqgrqkv29xr1h1142qsbmknlshpgys7fc3w1nkyhib8s3ikamg";
+ };
+ dependencies = [
+ "chronic"
+ "highline"
+ "locale"
+ "lockfile"
+ "mime-types"
+ "ncursesw"
+ "rmail-sup"
+ "trollop"
+ "unicode"
+ ];
+ };
+ "trollop" = {
+ version = "2.1.1";
+ source = {
+ type = "gem";
+ sha256 = "0z5dvh7glwqjprlihsjx67hfzy4whsjfhqj9akyyrby9q5va1i4k";
+ };
+ };
+ "unicode" = {
+ version = "0.4.4.2";
+ source = {
+ type = "gem";
+ sha256 = "15fggljzan8zvmr8h12b5m7pcj1gvskmmnx367xs4p0rrpnpil8g";
+ };
+ };
+ "xapian-ruby" = {
+ version = "1.2.19.1";
+ source = {
+ type = "gem";
+ sha256 = "1crfrmc8kf6qq1xcfcmgf213zg66badpg4d86n7y9x3i1f5lxlbv";
+ };
+ };
+}
\ No newline at end of file
diff --git a/pkgs/applications/version-management/git-and-tools/hub/default.nix b/pkgs/applications/version-management/git-and-tools/hub/default.nix
index 3d8d3cb4355..be53a429e7b 100644
--- a/pkgs/applications/version-management/git-and-tools/hub/default.nix
+++ b/pkgs/applications/version-management/git-and-tools/hub/default.nix
@@ -10,7 +10,6 @@ stdenv.mkDerivation rec {
sha256 = "1f6r8vlwnmqmr85drfv24vhqx1aacz6s83c2i804v9997n0wrwfm";
};
-
buildInputs = [ go ];
phases = [ "unpackPhase" "buildPhase" "installPhase" ];
@@ -37,7 +36,6 @@ stdenv.mkDerivation rec {
# ?
'';
-
meta = with stdenv.lib; {
description = "Command-line wrapper for git that makes you better at GitHub";
diff --git a/pkgs/applications/version-management/redmine/bootstrap.nix b/pkgs/applications/version-management/redmine/bootstrap.nix
index 4b4359603c9..5971f2e9cdd 100644
--- a/pkgs/applications/version-management/redmine/bootstrap.nix
+++ b/pkgs/applications/version-management/redmine/bootstrap.nix
@@ -14,7 +14,7 @@ in stdenv.mkDerivation rec {
sha256 = "0x0zwxyj4dwbk7l64s3lgny10mjf0ba8jwrbafsm4d72sncmacv0";
};
buildInputs = [
- ruby rubyLibs.bundler libiconv libxslt libxml2 pkgconfig
+ ruby bundler libiconv libxslt libxml2 pkgconfig
libffi imagemagickBig postgresql which stdenv
];
installPhase = ''
diff --git a/pkgs/applications/version-management/redmine/default.nix b/pkgs/applications/version-management/redmine/default.nix
index a4254384e5b..b1ef5ee757c 100644
--- a/pkgs/applications/version-management/redmine/default.nix
+++ b/pkgs/applications/version-management/redmine/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, ruby, rubyLibs, libiconv, libiconvOrNull, libiconvOrLibc, libxslt, libxml2, pkgconfig, libffi, glibc, imagemagickBig, postgresql }:
+{ stdenv, fetchurl, ruby, bundler, libiconv, libiconvOrNull, libiconvOrLibc, libxslt, libxml2, pkgconfig, libffi, glibc, imagemagickBig, postgresql }:
let
gemspec = map (gem: fetchurl { url=gem.url; sha256=gem.hash; }) (import ./Gemfile.nix);
@@ -25,7 +25,7 @@ in stdenv.mkDerivation rec {
'';
buildInputs = [
- ruby rubyLibs.bundler
+ ruby bundler
] ++ (if (libiconvOrNull != null) then [libiconv] else []) ++ [
libxslt libxml2 pkgconfig libffi
imagemagickBig postgresql
diff --git a/pkgs/development/interpreters/ruby/bundix/Gemfile b/pkgs/development/interpreters/ruby/bundix/Gemfile
new file mode 100644
index 00000000000..b9ae407c4d4
--- /dev/null
+++ b/pkgs/development/interpreters/ruby/bundix/Gemfile
@@ -0,0 +1,4 @@
+source "http://rubygems.org"
+gem "bundix",
+ :git => "https://github.com/cstrahan/bundix.git",
+ :ref => "5df25b11b5b86e636754d54c2a8859c7c6ec78c7"
diff --git a/pkgs/development/interpreters/ruby/bundix/Gemfile.lock b/pkgs/development/interpreters/ruby/bundix/Gemfile.lock
new file mode 100644
index 00000000000..c8869fdb1e3
--- /dev/null
+++ b/pkgs/development/interpreters/ruby/bundix/Gemfile.lock
@@ -0,0 +1,19 @@
+GIT
+ remote: https://github.com/cstrahan/bundix.git
+ revision: 5df25b11b5b86e636754d54c2a8859c7c6ec78c7
+ ref: 5df25b11b5b86e636754d54c2a8859c7c6ec78c7
+ specs:
+ bundix (0.1.0)
+ bundler (~> 1.7.9)
+ thor (~> 0.19.1)
+
+GEM
+ remote: http://rubygems.org/
+ specs:
+ thor (0.19.1)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ bundix!
diff --git a/pkgs/development/interpreters/ruby/bundix/default.nix b/pkgs/development/interpreters/ruby/bundix/default.nix
new file mode 100644
index 00000000000..0196adb8f4c
--- /dev/null
+++ b/pkgs/development/interpreters/ruby/bundix/default.nix
@@ -0,0 +1,9 @@
+{ ruby, bundlerEnv }:
+
+bundlerEnv {
+ name = "bundix";
+ inherit ruby;
+ gemset = ./gemset.nix;
+ gemfile = ./Gemfile;
+ lockfile = ./Gemfile.lock;
+}
diff --git a/pkgs/development/interpreters/ruby/bundix/gemset.nix b/pkgs/development/interpreters/ruby/bundix/gemset.nix
new file mode 100644
index 00000000000..a2c633f903c
--- /dev/null
+++ b/pkgs/development/interpreters/ruby/bundix/gemset.nix
@@ -0,0 +1,22 @@
+{
+ "bundix" = {
+ version = "0.1.0";
+ source = {
+ type = "git";
+ url = "https://github.com/cstrahan/bundix.git";
+ rev = "5df25b11b5b86e636754d54c2a8859c7c6ec78c7";
+ fetchSubmodules = false;
+ sha256 = "0334jsavpzkikcs7wrx7a3r0ilvr5vsnqd34lhc58b8cgvgll47p";
+ };
+ dependencies = [
+ "thor"
+ ];
+ };
+ "thor" = {
+ version = "0.19.1";
+ source = {
+ type = "gem";
+ sha256 = "08p5gx18yrbnwc6xc0mxvsfaxzgy2y9i78xq7ds0qmdm67q39y4z";
+ };
+ };
+}
diff --git a/pkgs/development/interpreters/ruby/bundler-env/default-gem-config.nix b/pkgs/development/interpreters/ruby/bundler-env/default-gem-config.nix
new file mode 100644
index 00000000000..7b10cd152e5
--- /dev/null
+++ b/pkgs/development/interpreters/ruby/bundler-env/default-gem-config.nix
@@ -0,0 +1,115 @@
+# The standard set of gems in nixpkgs including potential fixes.
+#
+# The gemset is derived from two points of entry:
+# - An attrset describing a gem, including version, source and dependencies
+# This is just meta data, most probably automatically generated by a tool
+# like Bundix (https://github.com/aflatter/bundix).
+# {
+# name = "bundler";
+# version = "1.6.5";
+# sha256 = "1s4x0f5by9xs2y24jk6krq5ky7ffkzmxgr4z1nhdykdmpsi2zd0l";
+# dependencies = [ "rake" ];
+# }
+# - An optional derivation that may override how the gem is built. For popular
+# gems that don't behave correctly, fixes are already provided in the form of
+# derivations.
+#
+# This seperates "what to build" (the exact gem versions) from "how to build"
+# (to make gems behave if necessary).
+
+{ lib, fetchurl, writeScript, ruby, libxml2, libxslt, python, stdenv, which
+, libiconv, postgresql, v8, v8_3_16_14, clang, sqlite, zlib, imagemagick, pkgconfig
+, ncurses, xapian, gpgme, utillinux, fetchpatch
+}:
+
+let
+ v8 = v8_3_16_14;
+
+in
+
+{
+ gpgme = attrs: {
+ buildInputs = [ gpgme ];
+ };
+
+ libv8 = attrs: {
+ buildInputs = [ which v8 python ];
+ buildFlags = [
+ "--with-system-v8=true"
+ ];
+ patches = [
+ (fetchpatch {
+ url = https://github.com/cowboyd/libv8/pull/161.patch;
+ sha256 = "1l6572cmigc22g249jj8h0xlbig88mj43kdqdbimhw2pmpv3q0rs";
+ })
+ ];
+ };
+
+ ncursesw = attrs: {
+ buildInputs = [ ncurses ];
+ buildFlags = [
+ "--with-cflags=-I${ncurses}/include"
+ "--with-ldflags=-L${ncurses}/lib"
+ ];
+ };
+
+ nokogiri = attrs: {
+ buildFlags = [
+ "--use-system-libraries"
+ "--with-zlib-dir=${zlib}"
+ "--with-xml2-lib=${libxml2}/lib"
+ "--with-xml2-include=${libxml2}/include/libxml2"
+ "--with-xslt-lib=${libxslt}/lib"
+ "--with-xslt-include=${libxslt}/include"
+ "--with-exslt-lib=${libxslt}/lib"
+ "--with-exslt-include=${libxslt}/include"
+ ] ++ lib.optional stdenv.isDarwin "--with-iconv-dir=${libiconv}";
+ };
+
+ pg = attrs: {
+ buildFlags = [
+ "--with-pg-config=${postgresql}/bin/pg_config"
+ ];
+ };
+
+ rmagick = attrs: {
+ buildInputs = [ imagemagick pkgconfig ];
+ };
+
+ sqlite3 = attrs: {
+ buildFlags = [
+ "--with-sqlite3-include=${sqlite}/include"
+ "--with-sqlite3-lib=${sqlite}/lib"
+ ];
+ };
+
+ sup = attrs: {
+ # prevent sup from trying to dynamically install `xapian-ruby`.
+ postPatch = ''
+ cp ${./mkrf_conf_xapian.rb} ext/mkrf_conf_xapian.rb
+
+ substituteInPlace lib/sup/crypto.rb \
+ --replace 'which gpg2' \
+ '${which}/bin/which gpg2'
+ '';
+ };
+
+ therubyracer = attrs: {
+ buildFlags = [
+ "--with-v8-dir=${v8}"
+ "--with-v8-include=${v8}/include"
+ "--with-v8-lib=${v8}/lib"
+ ];
+ };
+
+ xapian-ruby = attrs: {
+ # use the system xapian
+ buildInputs = [ xapian pkgconfig zlib ];
+ postPatch = ''
+ cp ${./xapian-Rakefile} Rakefile
+ '';
+ preInstall = ''
+ export XAPIAN_CONFIG=${xapian}/bin/xapian-config
+ '';
+ };
+}
diff --git a/pkgs/development/interpreters/ruby/bundler-env/default.nix b/pkgs/development/interpreters/ruby/bundler-env/default.nix
new file mode 100644
index 00000000000..fc23e3547b6
--- /dev/null
+++ b/pkgs/development/interpreters/ruby/bundler-env/default.nix
@@ -0,0 +1,306 @@
+{ stdenv, runCommand, writeText, writeScript, writeScriptBin, ruby, lib
+, callPackage, defaultGemConfig, fetchurl, fetchgit, buildRubyGem , bundler_HEAD
+, git
+}@defs:
+
+# This is a work-in-progress.
+# The idea is that his will replace load-ruby-env.nix.
+
+{ name, gemset, gemfile, lockfile, ruby ? defs.ruby, gemConfig ? defaultGemConfig
+, enableParallelBuilding ? false # TODO: this might not work, given the env-var shinanigans.
+, documentation ? false
+, meta ? {}
+}@args:
+
+let
+
+ shellEscape = x: "'${lib.replaceChars ["'"] [("'\\'" + "'")] x}'";
+ const = x: y: x;
+ bundler = bundler_HEAD.override { inherit ruby; };
+ inherit (builtins) attrValues;
+
+ gemName = attrs: "${attrs.name}-${attrs.version}.gem";
+
+ fetchers.path = attrs: attrs.source.path;
+ fetchers.gem = attrs: fetchurl {
+ url = "${attrs.source.source or "https://rubygems.org"}/downloads/${gemName attrs}";
+ inherit (attrs.source) sha256;
+ };
+ fetchers.git = attrs: fetchgit {
+ inherit (attrs.source) url rev sha256 fetchSubmodules;
+ leaveDotGit = true;
+ };
+
+ applySrc = attrs:
+ attrs // {
+ src = (fetchers."${attrs.source.type}" attrs);
+ };
+
+ applyGemConfigs = attrs:
+ if gemConfig ? "${attrs.name}"
+ then attrs // gemConfig."${attrs.name}" attrs
+ else attrs;
+
+ needsPatch = attrs:
+ (attrs ? patches) || (attrs ? prePatch) || (attrs ? postPatch);
+
+ # patch a gem or source tree.
+ # for gems, the gem is unpacked, patched, and then repacked.
+ # see: https://github.com/fedora-ruby/gem-patch/blob/master/lib/rubygems/patcher.rb
+ applyPatches = attrs:
+ if !needsPatch attrs
+ then attrs
+ else attrs // { src =
+ stdenv.mkDerivation {
+ name = gemName attrs;
+ phases = [ "unpackPhase" "patchPhase" "installPhase" ];
+ buildInputs = [ ruby ] ++ attrs.buildInputs or [];
+ patches = attrs.patches or [ ];
+ prePatch = attrs.prePatch or "true";
+ postPatch = attrs.postPatch or "true";
+ unpackPhase = ''
+ runHook preUnpack
+
+ if [[ -f ${attrs.src} ]]; then
+ isGem=1
+ # we won't know the name of the directory that RubyGems creates,
+ # so we'll just use a glob to find it and move it over.
+ gem unpack ${attrs.src} --target=container
+ cp -r container/* contents
+ rm -r container
+ else
+ cp -r ${attrs.src} contents
+ chmod -R +w contents
+ fi
+
+ cd contents
+ runHook postUnpack
+ '';
+ installPhase = ''
+ runHook preInstall
+
+ if [[ -n "$isGem" ]]; then
+ ${writeScript "repack.rb" ''
+ #!${ruby}/bin/ruby
+ require 'rubygems'
+ require 'rubygems/package'
+ require 'fileutils'
+
+ if defined?(Encoding.default_internal)
+ Encoding.default_internal = Encoding::UTF_8
+ Encoding.default_external = Encoding::UTF_8
+ end
+
+ if Gem::VERSION < '2.0'
+ load "${./package-1.8.rb}"
+ end
+
+ out = ENV['out']
+ files = Dir['**/{.[^\.]*,*}']
+
+ package = Gem::Package.new("${attrs.src}")
+ patched_package = Gem::Package.new(package.spec.file_name)
+ patched_package.spec = package.spec.clone
+ patched_package.spec.files = files
+
+ patched_package.build(false)
+
+ FileUtils.cp(patched_package.spec.file_name, out)
+ ''}
+ else
+ cp -r . out
+ fi
+
+ runHook postInstall
+ '';
+ };
+ };
+
+ instantiate = (attrs:
+ applyPatches (applyGemConfigs (applySrc attrs))
+ );
+
+ instantiated = lib.flip lib.mapAttrs (import gemset) (name: attrs:
+ instantiate (attrs // { inherit name; })
+ );
+
+ needsPreInstall = attrs:
+ (attrs ? preInstall) || (attrs ? buildInputs) || (attrs ? nativeBuildInputs);
+
+ # TODO: support cross compilation? look at stdenv/generic/default.nix.
+ runPreInstallers = lib.fold (next: acc:
+ if !needsPreInstall next
+ then acc
+ else acc + ''
+ ${writeScript "${next.name}-pre-install" ''
+ #!${stdenv.shell}
+
+ export nativeBuildInputs="${toString ((next.nativeBuildInputs or []) ++ (next.buildInputs or []))}"
+
+ source ${stdenv}/setup
+
+ header "running pre-install script for ${next.name}"
+
+ ${next.preInstall or ""}
+
+ ${ruby}/bin/ruby -e 'print ENV.inspect' > env/${next.name}
+
+ stopNest
+ ''}
+ ''
+ ) "" (attrValues instantiated);
+
+ # copy *.gem to ./gems
+ copyGems = lib.fold (next: acc:
+ if next.source.type == "gem"
+ then acc + "cp ${next.src} gems/${gemName next}\n"
+ else acc
+ ) "" (attrValues instantiated);
+
+ runRuby = name: env: command:
+ runCommand name env ''
+ ${ruby}/bin/ruby ${writeText name command}
+ '';
+
+ # TODO: include json_pure, so the version of ruby doesn't matter.
+ # not all rubies have support for JSON built-in,
+ # so we'll convert JSON to ruby expressions.
+ json2rb = writeScript "json2rb" ''
+ #!${ruby}/bin/ruby
+ begin
+ require 'json'
+ rescue LoadError => ex
+ require 'json_pure'
+ end
+
+ puts JSON.parse(STDIN.read).inspect
+ '';
+
+ # dump the instantiated gemset as a ruby expression.
+ serializedGemset = runCommand "gemset.rb" { json = builtins.toJSON instantiated; } ''
+ printf '%s' "$json" | ${json2rb} > $out
+ '';
+
+ # this is a mapping from a source type and identifier (uri/path/etc)
+ # to the pure store path.
+ # we'll use this from the patched bundler to make fetching sources pure.
+ sources = runRuby "sources.rb" { gemset = serializedGemset; } ''
+ out = ENV['out']
+ gemset = eval(File.read(ENV['gemset']))
+
+ sources = {
+ "git" => { },
+ "path" => { },
+ "gem" => { },
+ "svn" => { }
+ }
+
+ gemset.each_value do |spec|
+ type = spec["source"]["type"]
+ val = spec["src"]
+ key =
+ case type
+ when "gem"
+ spec["name"]
+ when "git"
+ spec["source"]["url"]
+ when "path"
+ spec["source"]["originalPath"]
+ when "svn"
+ nil # TODO
+ end
+
+ sources[type][key] = val if key
+ end
+
+ File.open(out, "wb") do |f|
+ f.print sources.inspect
+ end
+ '';
+
+ # rewrite PATH sources to point into the nix store.
+ purifiedLockfile = runRuby "purifiedLockfile" {} ''
+ out = ENV['out']
+ sources = eval(File.read("${sources}"))
+ paths = sources["path"]
+
+ lockfile = File.read("${lockfile}")
+
+ paths.each_pair do |impure, pure|
+ lockfile.gsub!(/^ remote: #{Regexp.escape(impure)}/, " remote: #{pure}")
+ end
+
+ File.open(out, "wb") do |f|
+ f.print lockfile
+ end
+ '';
+
+ needsBuildFlags = attrs: attrs ? buildFlags;
+
+ mkBuildFlags = spec:
+ "export BUNDLE_BUILD__${lib.toUpper spec.name}='${lib.concatStringsSep " " (map shellEscape spec.buildFlags)}'";
+
+ allBuildFlags =
+ lib.concatStringsSep "\n"
+ (map mkBuildFlags
+ (lib.filter needsBuildFlags (attrValues instantiated)));
+
+in
+
+stdenv.mkDerivation {
+ inherit name;
+
+ buildInputs = [
+ ruby
+ bundler
+ git
+ ];
+
+ phases = [ "installPhase" "fixupPhase" ];
+
+ outputs = [
+ "out" # the installed libs/bins
+ "bundle" # supporting files for bundler
+ ];
+
+ installPhase = ''
+ mkdir -p $bundle
+ export BUNDLE_GEMFILE=$bundle/Gemfile
+ cp ${gemfile} $BUNDLE_GEMFILE
+ cp ${purifiedLockfile} $BUNDLE_GEMFILE.lock
+
+ export NIX_GEM_SOURCES=${sources}
+ export NIX_BUNDLER_GEMPATH=${bundler}/${ruby.gemPath}
+
+ export GEM_HOME=$out/${ruby.gemPath}
+ export GEM_PATH=$GEM_HOME
+ mkdir -p $GEM_HOME
+
+ ${allBuildFlags}
+ #export
+
+ mkdir gems
+ ${copyGems}
+
+ ${lib.optionalString (!documentation) ''
+ mkdir home
+ HOME="$(pwd -P)/home"
+ echo "gem: --no-rdoc --no-ri" > $HOME/.gemrc
+ ''}
+
+ mkdir env
+ ${runPreInstallers}
+
+ mkdir $out/bin
+ cp ${./monkey_patches.rb} monkey_patches.rb
+ export RUBYOPT="-rmonkey_patches.rb -I $(pwd -P)"
+ bundler install --frozen --binstubs ${lib.optionalString enableParallelBuilding "--jobs $NIX_BUILD_CORES"}
+ '';
+
+ passthru = {
+ inherit ruby;
+ inherit bundler;
+ };
+
+ inherit meta;
+}
diff --git a/pkgs/development/interpreters/ruby/bundler-env/mkrf_conf_xapian.rb b/pkgs/development/interpreters/ruby/bundler-env/mkrf_conf_xapian.rb
new file mode 100644
index 00000000000..e19f06e23ac
--- /dev/null
+++ b/pkgs/development/interpreters/ruby/bundler-env/mkrf_conf_xapian.rb
@@ -0,0 +1,14 @@
+require 'rubygems'
+require 'rubygems/command.rb'
+require 'rubygems/dependency_installer.rb'
+require 'rbconfig'
+
+begin
+ Gem::Command.build_args = ARGV
+rescue NoMethodError
+end
+
+# create dummy rakefile to indicate success
+f = File.open(File.join(File.dirname(__FILE__), "Rakefile"), "w")
+f.write("task :default\n")
+f.close
diff --git a/pkgs/development/interpreters/ruby/bundler-env/monkey_patches.rb b/pkgs/development/interpreters/ruby/bundler-env/monkey_patches.rb
new file mode 100644
index 00000000000..5877f2e7bfb
--- /dev/null
+++ b/pkgs/development/interpreters/ruby/bundler-env/monkey_patches.rb
@@ -0,0 +1,238 @@
+require 'bundler'
+
+# Undo the RUBYOPT trickery.
+opt = ENV['RUBYOPT'].dup
+opt.gsub!(/-rmonkey_patches.rb -I [^ ]*/, '')
+ENV['RUBYOPT'] = opt
+
+Bundler.module_eval do
+ class << self
+ # mappings from original uris to store paths.
+ def nix_gem_sources
+ @nix_gem_sources ||=
+ begin
+ src = ENV['NIX_GEM_SOURCES']
+ eval(Bundler.read_file(src))
+ end
+ end
+
+ # extract the gemspecs from the gems pulled from Rubygems.
+ def nix_gemspecs
+ @nix_gemspecs ||= Dir.glob("gems/*.gem").map do |path|
+ Bundler.rubygems.spec_from_gem(path)
+ end
+ end
+
+ # swap out ENV
+ def nix_with_env(env, &block)
+ if env
+ old_env = ENV.to_hash
+ begin
+ ENV.replace(env)
+ block.call
+ ensure
+ ENV.replace(old_env)
+ end
+ else
+ block.call
+ end
+ end
+
+ # map a git uri to a fetchgit store path.
+ def nix_git(uri)
+ Pathname.new(nix_gem_sources["git"][uri])
+ end
+ end
+end
+
+Bundler::Source::Git::GitProxy.class_eval do
+ def checkout
+ unless path.exist?
+ FileUtils.mkdir_p(path.dirname)
+ FileUtils.cp_r(Bundler.nix_git(@uri).join(".git"), path)
+ system("chmod -R +w #{path}")
+ end
+ end
+
+ def copy_to(destination, submodules=false)
+ unless File.exist?(destination.join(".git"))
+ FileUtils.mkdir_p(destination.dirname)
+ FileUtils.cp_r(Bundler.nix_git(@uri), destination)
+ system("chmod -R +w #{destination}")
+ end
+ end
+end
+
+Bundler::Fetcher.class_eval do
+ def use_api
+ true
+ end
+
+ def fetch_dependency_remote_specs(gem_names)
+ Bundler.ui.debug "Query Gemcutter Dependency Endpoint API: #{gem_names.join(',')}"
+ deps_list = []
+
+ spec_list = gem_names.map do |name|
+ spec = Bundler.nix_gemspecs.detect {|spec| spec.name == name }
+ dependencies = spec.dependencies.
+ select {|dep| dep.type != :development}.
+ map do |dep|
+ deps_list << dep.name
+ dep
+ end
+
+ [spec.name, spec.version, spec.platform, dependencies]
+ end
+
+ [spec_list, deps_list.uniq]
+ end
+end
+
+Bundler::Source::Rubygems.class_eval do
+ # We copy all gems into $PWD/gems, and this allows RubyGems to find those
+ # gems during installation.
+ def fetchers
+ @fetchers ||= [
+ Bundler::Fetcher.new(URI.parse("file://#{File.expand_path(Dir.pwd)}"))
+ ]
+ end
+
+ # Look-up gems that were originally from RubyGems.
+ def remote_specs
+ @remote_specs ||=
+ begin
+ lockfile = Bundler::LockfileParser.new(Bundler.read_file(Bundler.default_lockfile))
+ gem_names = lockfile.specs.
+ select {|spec| spec.source.is_a?(Bundler::Source::Rubygems)}.
+ map {|spec| spec.name}
+ idx = Bundler::Index.new
+ api_fetchers.each do |f|
+ Bundler.ui.info "Fetching source index from #{f.uri}"
+ idx.use f.specs(gem_names, self)
+ end
+ idx
+ end
+ end
+end
+
+Bundler::Installer.class_eval do
+
+ # WHY:
+ # This allows us to provide a typical Nix experience, where
+ # `buildInputs` and/or `preInstall` may set up the $PATH and other env-vars
+ # as needed. By swapping out the environment per install, we can have finer
+ # grained control than we would have otherwise.
+ #
+ # HOW:
+ # This is a wrapper around the original `install_gem_from_spec`.
+ # We expect that a "pre-installer" might exist at `pre-installers/`,
+ # and if it does, we execute it.
+ # The pre-installer is expected to dump its environment variables as a Ruby
+ # hash to `env/`.
+ # We then swap out the environment for the duration of the install,
+ # and then set it back to what it was originally.
+ alias original_install_gem_from_spec install_gem_from_spec
+ def install_gem_from_spec(spec, standalone = false, worker = 0)
+ env_dump = "env/#{spec.name}"
+ if File.exist?(env_dump)
+ env = eval(Bundler.read_file(env_dump))
+ unless env
+ Bundler.ui.error "The environment variables for #{spec.name} could not be loaded!"
+ exit 1
+ end
+ Bundler.nix_with_env(env) do
+ original_install_gem_from_spec(spec, standalone, worker)
+ end
+ else
+ original_install_gem_from_spec(spec, standalone, worker)
+ end
+ end
+
+ def generate_bundler_executable_stubs(spec, options = {})
+ return if spec.executables.empty?
+
+ out = ENV['out']
+
+ spec.executables.each do |executable|
+ next if executable == "bundle" || executable == "bundler"
+
+ binstub_path = "#{out}/bin/#{executable}"
+
+ File.open(binstub_path, 'w', 0777 & ~File.umask) do |f|
+ f.print <<-TEXT
+#!/usr/bin/env #{RbConfig::CONFIG['ruby_install_name']}
+
+old_gemfile = ENV["BUNDLE_GEMFILE"]
+old_gem_home = ENV["GEM_HOME"]
+old_gem_path = ENV["GEM_PATH"]
+
+ENV["BUNDLE_GEMFILE"] =
+ "#{ENV["BUNDLE_GEMFILE"]}"
+ENV["GEM_HOME"] =
+ "#{ENV["GEM_HOME"]}"
+ENV["GEM_PATH"] =
+ "#{ENV["NIX_BUNDLER_GEMPATH"]}:\#{ENV["GEM_HOME"]}\#{old_gem_path ? ":\#{old_gem_path}" : ""}}"
+
+require 'rubygems'
+require 'bundler/setup'
+
+ENV["BUNDLE_GEMFILE"] = old_gemfile
+ENV["GEM_HOME"] = old_gem_home
+ENV["GEM_PATH"] = old_gem_path
+
+load Gem.bin_path('#{spec.name}', '#{executable}')
+TEXT
+ end
+ end
+ end
+end
+
+Gem::Installer.class_eval do
+ # Make the wrappers automagically use bundler.
+ #
+ # Stage 1.
+ # Set $BUNDLE_GEMFILE so bundler knows what gems to load.
+ # Set $GEM_HOME to the installed gems, because bundler looks there for
+ # non-Rubygems installed gems (e.g. git/svn/path sources).
+ # Set $GEM_PATH to include both bundler and installed gems.
+ #
+ # Stage 2.
+ # Setup bundler, locking down the gem versions.
+ #
+ # Stage 3.
+ # Reset $BUNDLE_GEMFILE, $GEM_HOME, $GEM_PATH.
+ #
+ # Stage 4.
+ # Run the actual executable.
+ def app_script_text(bin_file_name)
+ return <<-TEXT
+#{shebang bin_file_name}
+#
+# This file was generated by Nix's RubyGems.
+#
+# The application '#{spec.name}' is installed as part of a gem, and
+# this file is here to facilitate running it.
+#
+
+old_gemfile = ENV["BUNDLE_GEMFILE"]
+old_gem_home = ENV["GEM_HOME"]
+old_gem_path = ENV["GEM_PATH"]
+
+ENV["BUNDLE_GEMFILE"] =
+ "#{ENV["BUNDLE_GEMFILE"]}"
+ENV["GEM_HOME"] =
+ "#{ENV["GEM_HOME"]}"
+ENV["GEM_PATH"] =
+ "#{ENV["NIX_BUNDLER_GEMPATH"]}:\#{ENV["GEM_HOME"]}\#{old_gem_path ? ":\#{old_gem_path}" : ""}}"
+
+require 'rubygems'
+require 'bundler/setup'
+
+ENV["BUNDLE_GEMFILE"] = old_gemfile
+ENV["GEM_HOME"] = old_gem_home
+ENV["GEM_PATH"] = old_gem_path
+
+load Gem.bin_path('#{spec.name}', '#{bin_file_name}')
+TEXT
+ end
+end
diff --git a/pkgs/development/interpreters/ruby/bundler-env/package-1.8.rb b/pkgs/development/interpreters/ruby/bundler-env/package-1.8.rb
new file mode 100644
index 00000000000..079b65f97ec
--- /dev/null
+++ b/pkgs/development/interpreters/ruby/bundler-env/package-1.8.rb
@@ -0,0 +1,29 @@
+require 'rubygems/installer'
+require 'rubygems/builder'
+
+# Simulate RubyGems 2.0 behavior.
+
+module Gem::Package
+ def self.new(gem)
+ @gem = gem
+ self
+ end
+
+ def self.extract_files(dir)
+ installer = Gem::Installer.new @gem
+ installer.unpack(dir)
+ end
+
+ def self.build(skip_validation=false)
+ builder = Gem::Builder.new(spec)
+ builder.build
+ end
+
+ def self.spec=(spec)
+ @spec = spec
+ end
+
+ def self.spec
+ @spec ||= Gem::Installer.new(@gem).spec
+ end
+end
diff --git a/pkgs/development/interpreters/ruby/bundler-env/xapian-Rakefile b/pkgs/development/interpreters/ruby/bundler-env/xapian-Rakefile
new file mode 100644
index 00000000000..9f0b8e72f08
--- /dev/null
+++ b/pkgs/development/interpreters/ruby/bundler-env/xapian-Rakefile
@@ -0,0 +1,38 @@
+# encoding: utf-8
+# Install the xapian binaries into the lib folder of the gem
+require 'rbconfig'
+
+c = RbConfig::CONFIG
+
+def system!(cmd)
+ puts cmd
+ system(cmd) or raise
+end
+
+source_dir = 'xapian_source'
+bindings = Dir["#{source_dir}/xapian-bindings-*"].first
+bindings = File.basename(bindings, ".tar.xz")
+
+task :default do
+ system! "tar -xJf #{source_dir}/#{bindings}.tar.xz"
+
+ prefix = Dir.pwd
+ ENV['LDFLAGS'] = "-L#{prefix}/lib"
+
+ system! "mkdir -p lib"
+
+ Dir.chdir bindings do
+ ENV['RUBY'] ||= "#{c['bindir']}/#{c['RUBY_INSTALL_NAME']}"
+ system! "./configure --prefix=#{prefix} --exec-prefix=#{prefix} --with-ruby"
+ system! "make clean all"
+ end
+
+ system! "cp -r #{bindings}/ruby/.libs/_xapian.* lib"
+ system! "cp #{bindings}/ruby/xapian.rb lib"
+
+ system! "rm lib/*.la"
+ system! "rm lib/*.lai"
+
+ system! "rm -R #{bindings}"
+ system! "rm -R #{source_dir}"
+end
diff --git a/pkgs/development/interpreters/ruby/bundler-head.nix b/pkgs/development/interpreters/ruby/bundler-head.nix
new file mode 100644
index 00000000000..2e8cfc8cbf1
--- /dev/null
+++ b/pkgs/development/interpreters/ruby/bundler-head.nix
@@ -0,0 +1,18 @@
+{ buildRubyGem, coreutils, fetchgit }:
+
+buildRubyGem {
+ name = "bundler-HEAD";
+ src = fetchgit {
+ url = "https://github.com/bundler/bundler.git";
+ rev = "a2343c9eabf5403d8ffcbca4dea33d18a60fc157";
+ sha256 = "1l4r55n1wzr817l225l6pm97li1mxg9icd8s51cpfihh91nkdz68";
+ leaveDotGit = true;
+ };
+ dontPatchShebangs = true;
+ postInstall = ''
+ find $out -type f -perm +0100 | while read f; do
+ substituteInPlace $f \
+ --replace "/usr/bin/env" "${coreutils}/bin/env"
+ done
+ '';
+}
diff --git a/pkgs/development/interpreters/ruby/bundler.nix b/pkgs/development/interpreters/ruby/bundler.nix
new file mode 100644
index 00000000000..cbec8d0ad75
--- /dev/null
+++ b/pkgs/development/interpreters/ruby/bundler.nix
@@ -0,0 +1,13 @@
+{ buildRubyGem, coreutils }:
+
+buildRubyGem {
+ name = "bundler-1.7.9";
+ sha256 = "1gd201rh17xykab9pbqp0dkxfm7b9jri02llyvmrc0c5bz2vhycm";
+ dontPatchShebangs = true;
+ postInstall = ''
+ find $out -type f -perm +0100 | while read f; do
+ substituteInPlace $f \
+ --replace "/usr/bin/env" "${coreutils}/bin/env"
+ done
+ '';
+}
diff --git a/pkgs/development/interpreters/ruby/fix-gem-nix-versions.patch b/pkgs/development/interpreters/ruby/fix-gem-nix-versions.patch
deleted file mode 100644
index c67eaff2ac5..00000000000
--- a/pkgs/development/interpreters/ruby/fix-gem-nix-versions.patch
+++ /dev/null
@@ -1,35 +0,0 @@
-diff --git a/lib/nix/gem-nix-command.rb b/lib/nix/gem-nix-command.rb
-index 8d3733e..ba942ff 100644
---- a/lib/nix/gem-nix-command.rb
-+++ b/lib/nix/gem-nix-command.rb
-@@ -108,11 +108,12 @@ class Gem::Commands::NixCommand < Gem::Command
-
- # args to dep informations
- args.each { |arg|
-- if arg =~ /(.+)-?(.*)?/ then
-+ if arg =~ /(.+)-([0-9][^-]+)/ then
- gem_name = $1
-- version = $2.empty? ? Gem::Requirement.default : Gem::Version.new($2)
-+ version = Gem::Version.new($2)
- else
-- raise Gem::CommandLineError, "couldn't parse arg. expected: name or name-version"
-+ gem_name = arg
-+ version = Gem::Requirement.default
- end
-
- adddep(Gem::Dependency.new gem_name, version)
-@@ -162,7 +163,13 @@ class Gem::Commands::NixCommand < Gem::Command
- spec, source_uri = find_gem_with_source(dep)
- full_name = spec.full_name
-
-- return if @gems_with_deps.key?(full_name)
-+ if @gems_with_deps.key?(full_name)
-+ unless @gems_with_deps[full_name].nil?
-+ return @gems_with_deps[full_name][0]
-+ else
-+ return nil
-+ end
-+ end
- @gems_with_deps[full_name] = nil # there maybe circular dependencies. thus mark this gem seen as early as possible
-
- # development deps can't be found. Some are old. Thus only add rutime dependencies
diff --git a/pkgs/development/interpreters/ruby/gem.nix b/pkgs/development/interpreters/ruby/gem.nix
index b5be8cf2b65..dd6338cd813 100644
--- a/pkgs/development/interpreters/ruby/gem.nix
+++ b/pkgs/development/interpreters/ruby/gem.nix
@@ -1,63 +1,136 @@
-{stdenv, fetchurl, ruby, rubygems, makeWrapper, patches, overrides}:
+{ lib, ruby, rubygemsFun, fetchurl, makeWrapper, git } @ defs:
-let
- gemDefaults = { name, basename, requiredGems, sha256, meta }:
- {
- buildInputs = [rubygems makeWrapper];
- unpackPhase = ":";
- configurePhase=":";
- bulidPhase=":";
+lib.makeOverridable (
- src = fetchurl {
- url = "http://rubygems.org/downloads/${name}.gem";
- inherit sha256;
+{ name
+, ruby ? defs.ruby
+, rubygems ? (rubygemsFun ruby)
+, stdenv ? ruby.stdenv
+, namePrefix ? "${ruby.name}" + "-"
+, buildInputs ? []
+, doCheck ? false
+, dontBuild ? true
+, meta ? {}
+, gemPath ? []
+, ...} @ attrs:
+
+stdenv.mkDerivation (attrs // {
+ inherit ruby rubygems;
+ inherit doCheck;
+
+ buildInputs = [ ruby rubygems makeWrapper git ] ++ buildInputs;
+
+ name = namePrefix + name;
+
+ src = if attrs ? src
+ then attrs.src
+ else fetchurl {
+ url = "http://rubygems.org/downloads/${attrs.name}.gem";
+ inherit (attrs) sha256;
};
- name = "ruby-${name}";
+ phases = [ "unpackPhase" "patchPhase" "buildPhase" "checkPhase" "installPhase" "fixupPhase" ];
- propagatedBuildInputs = requiredGems ++ [ruby];
+ # The source is expected to either be a gem package or a directory.
+ #
+ # - Gem packages are already built, so they don't even need to be unpacked.
+ # They will skip the buildPhase.
+ # - A directory containing the sources will need to go through all of the
+ # usual phases.
+ unpackPhase= ''
+ gemRegex="\.gem"
+ if [[ $src =~ $gemRegex ]]
+ then
+ runHook preUnpack
+ echo "source is a gem package, won't unpack"
+ gempkg=$src
+ dontBuild=1
+ runHook postUnpack
+ else
+ # Fall back to the original thing for everything else.
+ unpackPhase
+ fi
+ '';
- inherit meta;
+ checkPhase = "true";
- installPhase = ''
- export HOME=$TMP/home; mkdir -pv "$HOME"
+ buildPhase = ''
+ runHook preBuild
- gem install -V --ignore-dependencies \
- -i "$out/${ruby.gemPath}" -n "$out/bin" "$src" $gemFlags -- $buildFlags
- rm -frv $out/${ruby.gemPath}/cache # don't keep the .gem file here
+ # TODO: Investigate. The complete working tree is touched by fetchgit.
+ if [ -d .git ]; then
+ git reset
+ fi
+ gemspec=$(find . -name '*.gemspec')
+ echo "found the following gemspecs:"
+ echo "$gemspec"
+
+ gemspec=$(echo "$gemspec" | head -n1)
+ echo "building $gemspec"
+
+ exec 3>&1
+ output=$(gem build $gemspec | tee >(cat - >&3))
+ exec 3>&-
+
+ gempkg=$(echo "$output" | grep -oP 'File: \K(.*)')
+
+ echo "gem package built: $gempkg"
+
+ runHook postBuild
+ '';
+
+ installPhase = ''
+ runHook preInstall
+
+ # NOTE: This does NOT build the unpacked gem, but installs $src directly.
+ # Gems that have not been downloaded from rubygems.org may need a
+ # separate buildPhase.
+ # --ignore-dependencies is necessary as rubygems otherwise always
+ # connects to the repository, thus breaking pure builds.
+ GEM_HOME=$out/${ruby.gemPath} \
+ gem install \
+ --local \
+ --force \
+ --http-proxy "http://nodtd.invalid" \
+ --ignore-dependencies \
+ --build-root "/" \
+ --backtrace \
+ $gempkg $gemFlags -- $buildFlags
+
+ # Yes, we really do need the $out/${ruby.gemPath}/cache.
+ # This is very important in order for many parts of RubyGems/Bundler to not blow up.
+ # See https://github.com/bundler/bundler/issues/3327
+
+ mkdir -p $out/bin
+ for prog in $out/${ruby.gemPath}/gems/*/bin/*; do
+ makeWrapper $prog $out/bin/$(basename $prog) \
+ --prefix GEM_PATH : "$out/${ruby.gemPath}:$GEM_PATH" \
+ --prefix RUBYLIB : "${rubygems}/lib" \
+ $extraWrapperFlags ''${extraWrapperFlagsArray[@]}
+ done
+ #--prefix RUBYOPT rubygems \
+
+ # looks like useless files which break build repeatability and consume space
+ rm -fv $out/${ruby.gemPath}/doc/*/*/created.rid || true
+ rm -fv $out/${ruby.gemPath}/gems/*/ext/*/mkmf.log || true
+
+ mkdir -p $out/nix-support
+
+ cat > $out/nix-support/setup-hook < 3.16.14.0)
+ ref
+ uglifier (2.5.0)
+ execjs (>= 0.3.0)
+ json (>= 1.8.0)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ sass
+ therubyracer
+ uglifier
diff --git a/pkgs/servers/consul/default.nix b/pkgs/servers/consul/default.nix
index 49a3dac14ea..afe4a8e127d 100644
--- a/pkgs/servers/consul/default.nix
+++ b/pkgs/servers/consul/default.nix
@@ -1,8 +1,15 @@
-{ stdenv, lib, go, fetchgit, fetchhg, fetchbzr, fetchFromGitHub
-, ruby, rubyLibs, nodejs }:
+{ stdenv, lib, go, fetchgit, fetchhg, fetchbzr, fetchFromGitHub , ruby , nodejs
+, bundlerEnv }:
let
version = "0.4.1";
+ # `sass` et al
+ gems = bundlerEnv {
+ name = "consul-deps";
+ gemfile = ./Gemfile;
+ lockfile = ./Gemfile.lock;
+ gemset = ./gemset.nix;
+ };
in
with lib;
@@ -13,13 +20,7 @@ stdenv.mkDerivation {
inherit stdenv lib fetchgit fetchhg fetchbzr fetchFromGitHub;
};
- buildInputs = [ go ruby rubyLibs.sass nodejs ];
-
- configurePhase = flip concatMapStrings
- (with rubyLibs; [ execjs json minitest rake rdoc sass uglifier ])
- (gem: ''
- export GEM_PATH="$GEM_PATH:${gem}/${ruby.gemPath}"
- '');
+ buildInputs = [ go ruby gems nodejs ];
buildPhase = ''
# Build consul binary
diff --git a/pkgs/servers/consul/gemset.nix b/pkgs/servers/consul/gemset.nix
new file mode 100644
index 00000000000..bf417f8c411
--- /dev/null
+++ b/pkgs/servers/consul/gemset.nix
@@ -0,0 +1,59 @@
+{
+ execjs = {
+ version = "2.0.2";
+ source = {
+ type = "gem";
+ sha256 = "167kbkyql7nvvwjsgdw5z8j66ngq7kc59gxfwsxhqi5fl1z0jbjs";
+ };
+ };
+ json = {
+ version = "1.8.1";
+ source = {
+ type = "gem";
+ sha256 = "0002bsycvizvkmk1jyv8px1hskk6wrjfk4f7x5byi8gxm6zzn6wn";
+ };
+ };
+ libv8 = {
+ version = "3.16.14.3";
+ source = {
+ type = "gem";
+ sha256 = "1arjjbmr9zxkyv6pdrihsz1p5cadzmx8308vgfvrhm380ccgridm";
+ };
+ };
+ ref = {
+ version = "1.0.5";
+ source = {
+ type = "gem";
+ sha256 = "19qgpsfszwc2sfh6wixgky5agn831qq8ap854i1jqqhy1zsci3la";
+ };
+ };
+ sass = {
+ version = "3.3.6";
+ source = {
+ type = "gem";
+ sha256 = "0ra0kxx52cgyrq6db7a1vysk984ilshbx40bcf527k8b3fha6k5r";
+ };
+ };
+ therubyracer = {
+ version = "0.12.1";
+ source = {
+ type = "gem";
+ sha256 = "106fqimqyaalh7p6czbl5m2j69z8gv7cm10mjb8bbb2p2vlmqmi6";
+ };
+ dependencies = [
+ "libv8"
+ "ref"
+ ];
+ };
+ uglifier = {
+ version = "2.5.0";
+ source = {
+ type = "gem";
+ sha256 = "0b9kxgyg8cv3g1bp6casndfzfy71jd9xyjxwng0lj90vzqrgjp20";
+ };
+ dependencies = [
+ "execjs"
+ "json"
+ ];
+ };
+}
diff --git a/pkgs/servers/monitoring/riemann-dash/Gemfile b/pkgs/servers/monitoring/riemann-dash/Gemfile
new file mode 100644
index 00000000000..496302e7643
--- /dev/null
+++ b/pkgs/servers/monitoring/riemann-dash/Gemfile
@@ -0,0 +1,3 @@
+source 'https://rubygems.org'
+
+gem "riemann-dash", "0.2.9"
diff --git a/pkgs/servers/monitoring/riemann-dash/Gemfile.lock b/pkgs/servers/monitoring/riemann-dash/Gemfile.lock
new file mode 100644
index 00000000000..cd0ace470e2
--- /dev/null
+++ b/pkgs/servers/monitoring/riemann-dash/Gemfile.lock
@@ -0,0 +1,27 @@
+GEM
+ remote: https://rubygems.org/
+ specs:
+ erubis (2.7.0)
+ multi_json (1.3.6)
+ rack (1.5.2)
+ rack-protection (1.5.3)
+ rack
+ riemann-dash (0.2.9)
+ erubis (>= 2.7.0)
+ multi_json (= 1.3.6)
+ sass (>= 3.1.14)
+ sinatra (~> 1.4.5)
+ webrick (~> 1.3.1)
+ sass (3.4.8)
+ sinatra (1.4.5)
+ rack (~> 1.4)
+ rack-protection (~> 1.4)
+ tilt (~> 1.3, >= 1.3.4)
+ tilt (1.4.1)
+ webrick (1.3.1)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ riemann-dash (= 0.2.9)
diff --git a/pkgs/servers/monitoring/riemann-dash/default.nix b/pkgs/servers/monitoring/riemann-dash/default.nix
new file mode 100644
index 00000000000..1afcd81d9be
--- /dev/null
+++ b/pkgs/servers/monitoring/riemann-dash/default.nix
@@ -0,0 +1,8 @@
+{ bundlerEnv }:
+
+bundlerEnv {
+ name = "riemann-dash-0.2.9";
+ gemfile = ./Gemfile;
+ lockfile = ./Gemfile.lock;
+ gemset = ./gemset.nix;
+}
diff --git a/pkgs/servers/monitoring/riemann-dash/gemset.nix b/pkgs/servers/monitoring/riemann-dash/gemset.nix
new file mode 100644
index 00000000000..f2e80e9aca4
--- /dev/null
+++ b/pkgs/servers/monitoring/riemann-dash/gemset.nix
@@ -0,0 +1,80 @@
+{
+ erubis = {
+ version = "2.7.0";
+ source = {
+ type = "gem";
+ sha256 = "1fj827xqjs91yqsydf0zmfyw9p4l2jz5yikg3mppz6d7fi8kyrb3";
+ };
+ };
+ multi_json = {
+ version = "1.3.6";
+ source = {
+ type = "gem";
+ sha256 = "0q2zjfvd2ibds9g9nzf2p1b47fc1wqliwfywv5pw85w15lmy91yr";
+ };
+ };
+ rack = {
+ version = "1.5.2";
+ source = {
+ type = "gem";
+ sha256 = "19szfw76cscrzjldvw30jp3461zl00w4xvw1x9lsmyp86h1g0jp6";
+ };
+ };
+ rack-protection = {
+ version = "1.5.3";
+ source = {
+ type = "gem";
+ sha256 = "0cvb21zz7p9wy23wdav63z5qzfn4nialik22yqp6gihkgfqqrh5r";
+ };
+ dependencies = [
+ "rack"
+ ];
+ };
+ riemann-dash = {
+ version = "0.2.9";
+ source = {
+ type = "gem";
+ sha256 = "0ws5wmjbv8w9lcr3i2mdinj2qm91p6c85k6c067i67cf0p90jxq3";
+ };
+ dependencies = [
+ "erubis"
+ "multi_json"
+ "sass"
+ "sinatra"
+ "webrick"
+ ];
+ };
+ sass = {
+ version = "3.4.8";
+ source = {
+ type = "gem";
+ sha256 = "1ianyj2figwk314h10fkzpjql2xxi5l4njv1h0w8iyzjda85rqlp";
+ };
+ };
+ sinatra = {
+ version = "1.4.5";
+ source = {
+ type = "gem";
+ sha256 = "0qyna3wzlnvsz69d21lxcm3ixq7db08mi08l0a88011qi4qq701s";
+ };
+ dependencies = [
+ "rack"
+ "rack-protection"
+ "tilt"
+ ];
+ };
+ tilt = {
+ version = "1.4.1";
+ source = {
+ type = "gem";
+ sha256 = "00sr3yy7sbqaq7cb2d2kpycajxqf1b1wr1yy33z4bnzmqii0b0ir";
+ };
+ };
+ webrick = {
+ version = "1.3.1";
+ source = {
+ type = "gem";
+ sha256 = "0s42mxihcl2bx0h9q0v2syl70qndydfkl39a06h9il17p895ya8g";
+ };
+ };
+}
diff --git a/pkgs/tools/audio/mpdcron/Gemfile b/pkgs/tools/audio/mpdcron/Gemfile
new file mode 100644
index 00000000000..e0814bc4dda
--- /dev/null
+++ b/pkgs/tools/audio/mpdcron/Gemfile
@@ -0,0 +1,2 @@
+source "https://rubygems.org"
+gem "nokogiri"
diff --git a/pkgs/tools/audio/mpdcron/Gemfile.lock b/pkgs/tools/audio/mpdcron/Gemfile.lock
new file mode 100644
index 00000000000..e97aaf669f7
--- /dev/null
+++ b/pkgs/tools/audio/mpdcron/Gemfile.lock
@@ -0,0 +1,12 @@
+GEM
+ remote: https://rubygems.org/
+ specs:
+ mini_portile (0.6.2)
+ nokogiri (1.6.5)
+ mini_portile (~> 0.6.0)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ nokogiri
diff --git a/pkgs/tools/audio/mpdcron/default.nix b/pkgs/tools/audio/mpdcron/default.nix
index a772feca5c5..d368ee321af 100644
--- a/pkgs/tools/audio/mpdcron/default.nix
+++ b/pkgs/tools/audio/mpdcron/default.nix
@@ -1,7 +1,14 @@
-{ stdenv, fetchgit, autoconf, automake, libtool, pkgconfig, glib, libdaemon
-, mpd_clientlib, curl, sqlite, ruby, rubyLibs, libnotify, pandoc }:
+{ stdenv, fetchgit, autoconf, automake, libtool, pkgconfig, glib, libdaemon, buildRubyGem
+, mpd_clientlib, curl, sqlite, ruby, bundlerEnv, libnotify, pandoc }:
-stdenv.mkDerivation rec {
+let
+ gemEnv = bundlerEnv {
+ name = "mpdcron-bundle";
+ gemfile = ./Gemfile;
+ lockfile = ./Gemfile.lock;
+ gemset = ./gemset.nix;
+ };
+in stdenv.mkDerivation rec {
version = "20130809";
name = "mpdcron-${version}";
@@ -21,7 +28,7 @@ stdenv.mkDerivation rec {
buildInputs =
[ autoconf automake libtool pkgconfig glib libdaemon pandoc
- mpd_clientlib curl sqlite ruby rubyLibs.nokogiri libnotify ];
+ mpd_clientlib curl sqlite ruby gemEnv libnotify ];
preConfigure = ''
./autogen.sh
diff --git a/pkgs/tools/audio/mpdcron/gemset.nix b/pkgs/tools/audio/mpdcron/gemset.nix
new file mode 100644
index 00000000000..6587603fb5b
--- /dev/null
+++ b/pkgs/tools/audio/mpdcron/gemset.nix
@@ -0,0 +1,19 @@
+{
+ "mini_portile" = {
+ version = "0.6.2";
+ source = {
+ type = "gem";
+ sha256 = "0h3xinmacscrnkczq44s6pnhrp4nqma7k056x5wv5xixvf2wsq2w";
+ };
+ };
+ "nokogiri" = {
+ version = "1.6.5";
+ source = {
+ type = "gem";
+ sha256 = "1xmxz6fa0m4p7c7ngpgz6gjgv65lzz63dsf0b6vh7gs2fkiw8j7l";
+ };
+ dependencies = [
+ "mini_portile"
+ ];
+ };
+}
\ No newline at end of file
diff --git a/pkgs/tools/package-management/gem-nix/default.nix b/pkgs/tools/package-management/gem-nix/default.nix
deleted file mode 100644
index e048122b287..00000000000
--- a/pkgs/tools/package-management/gem-nix/default.nix
+++ /dev/null
@@ -1,23 +0,0 @@
-{ stdenv, rubygems, rubyLibs, ruby, makeWrapper }:
-
-stdenv.mkDerivation rec {
- name = "gem-nix";
-
- buildInputs = [ ruby rubygems rubyLibs.nix makeWrapper ];
-
- phases = ["installPhase"];
-
- installPhase = ''
- mkdir -p $out/bin
- echo 'exec ${rubygems}/bin/gem nix "$@"' >> $out/bin/gem-nix
- chmod +x $out/bin/gem-nix
- wrapProgram $out/bin/gem-nix \
- --set GEM_PATH $GEM_PATH
- '';
-
- meta = with stdenv.lib; {
- description = "gem nix command in a nice wrapper";
- platforms = platforms.unix;
- maintainers = [ maintainers.iElectric ];
- };
-}
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index e7efc86f83a..180bb809ecf 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -680,7 +680,7 @@ let
cloud-init = callPackage ../tools/virtualization/cloud-init { };
consul = callPackage ../servers/consul {
- inherit ruby rubyLibs;
+ # inherit ruby;
};
consul_ui = consul.ui;
@@ -4306,6 +4306,18 @@ let
wrapPython = pythonPackages.wrapPython;
};
+ bundix = callPackage ../development/interpreters/ruby/bundix {
+ ruby = ruby_2_1_3;
+ };
+ bundler = callPackage ../development/interpreters/ruby/bundler.nix { };
+ bundler_HEAD = import ../development/interpreters/ruby/bundler-head.nix {
+ inherit buildRubyGem coreutils fetchgit;
+ };
+ defaultGemConfig = callPackage ../development/interpreters/ruby/bundler-env/default-gem-config.nix { };
+ buildRubyGem = callPackage ../development/interpreters/ruby/gem.nix { };
+ loadRubyEnv = callPackage ../development/interpreters/ruby/load-ruby-env.nix { };
+ bundlerEnv = callPackage ../development/interpreters/ruby/bundler-env { };
+
ruby_1_8_7 = callPackage ../development/interpreters/ruby/ruby-1.8.7.nix { };
ruby_1_9_3 = callPackage ../development/interpreters/ruby/ruby-1.9.3.nix { };
ruby_2_0_0 = lowPrio (callPackage ../development/interpreters/ruby/ruby-2.0.0.nix { });
@@ -4323,12 +4335,6 @@ let
ruby_2_1 = ruby_2_1_3;
ruby_2_2 = ruby_2_2_0;
- rubyLibs = recurseIntoAttrs (callPackage ../development/interpreters/ruby/libs.nix { });
-
- rake = rubyLibs.rake;
-
- rubySqlite3 = callPackage ../development/ruby-modules/sqlite3 { };
-
rubygemsFun = ruby: builderDefsPackage (import ../development/interpreters/ruby/rubygems.nix) {
inherit ruby makeWrapper;
};
@@ -7219,6 +7225,10 @@ let
ucommon = callPackage ../development/libraries/ucommon { };
+ v8_3_16_14 = callPackage ../development/libraries/v8/3.16.14.nix {
+ inherit (pythonPackages) gyp;
+ };
+
v8 = callPackage ../development/libraries/v8 {
inherit (pythonPackages) gyp;
};
@@ -7941,6 +7951,7 @@ let
newrelic-sysmond = callPackage ../servers/monitoring/newrelic-sysmond { };
riemann = callPackage ../servers/monitoring/riemann { };
+ riemann-dash = callPackage ../servers/monitoring/riemann-dash { };
oidentd = callPackage ../servers/identd/oidentd { };
@@ -10621,42 +10632,14 @@ let
pcmanfm = callPackage ../applications/misc/pcmanfm { };
- ruby_gpgme = callPackage ../development/libraries/ruby_gpgme {
- ruby = ruby_1_9_3;
- hoe = rubyLibs.hoe;
- };
-
- ruby_ncursesw_sup = callPackage ../development/libraries/ruby_ncursesw_sup { };
-
shotcut = callPackage ../applications/video/shotcut { mlt = mlt-qt5; };
smplayer = callPackage ../applications/video/smplayer { };
smtube = callPackage ../applications/video/smtube {};
- sup = with rubyLibs; callPackage ../applications/networking/mailreaders/sup {
- ruby = ruby_1_9_3.override {
- cursesSupport = true;
- };
-
- inherit gettext highline iconv locale lockfile
- text trollop xapian_ruby which;
-
- rmail_sup = ""; # missing
- unicode = "";
-
- # See https://github.com/NixOS/nixpkgs/issues/1804 and
- # https://github.com/NixOS/nixpkgs/issues/2146
- bundler = pkgs.lib.overrideDerivation pkgs.rubyLibs.bundler (
- oldAttrs: {
- dontPatchShebangs = 1;
- }
- );
- chronic = chronic;
- gpgme = ruby_gpgme;
- mime_types = mime_types;
- ncursesw_sup = ruby_ncursesw_sup;
- rake = rake;
+ sup = callPackage ../applications/networking/mailreaders/sup {
+ ruby = ruby_1_9_3.override { cursesSupport = true; };
};
synfigstudio = callPackage ../applications/graphics/synfigstudio {
diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix
index af0377e1464..6839996a60d 100644
--- a/pkgs/top-level/python-packages.nix
+++ b/pkgs/top-level/python-packages.nix
@@ -13156,7 +13156,7 @@ let
propagatedBuildInputs = with self; [ dateutil ];
preInstall = stdenv.lib.optionalString stdenv.isDarwin ''
- sed -i 's|^\([ ]*\)self.bin_path.*$|\1self.bin_path = "${pkgs.rubyLibs.terminal_notifier}/bin/terminal-notifier"|' build/lib/pync/TerminalNotifier.py
+ sed -i 's|^\([ ]*\)self.bin_path.*$|\1self.bin_path = "${pkgs.rubyPackages.terminal_notifier}/bin/terminal-notifier"|' build/lib/pync/TerminalNotifier.py
'';
meta = with stdenv.lib; {