From 7d8b2f0d60caea47b26692c94f86af70cec5bd20 Mon Sep 17 00:00:00 2001 From: Charles Strahan Date: Tue, 20 Jan 2015 22:20:28 -0500 Subject: [PATCH] ruby: make buildInputs work --- .../interpreters/ruby/bundler-env.nix | 7 +++++-- .../interpreters/ruby/bundler-head.nix | 2 +- .../interpreters/ruby/monkey_patches.rb | 17 +++++++++++++++-- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/pkgs/development/interpreters/ruby/bundler-env.nix b/pkgs/development/interpreters/ruby/bundler-env.nix index a2a3628d09c..5e471d36f2d 100644 --- a/pkgs/development/interpreters/ruby/bundler-env.nix +++ b/pkgs/development/interpreters/ruby/bundler-env.nix @@ -121,7 +121,7 @@ let ); needsPreInstall = attrs: - (attrs ? preInstall) || (attrs ? buildInputs); + (attrs ? preInstall) || (attrs ? buildInputs) || (attrs ? nativeBuildInputs); createPreInstallers = lib.fold (next: acc: if !needsPreInstall next @@ -129,12 +129,15 @@ let else acc + '' cp ${writeScript "${next.name}-pre-install" '' #!/bin/sh + buildInputs="${toString (next.buildInputs or [])}" + nativeBuildInputs="${toString (next.nativeBuildInputs or [])}" + source ${stdenv}/setup ${next.preInstall or ""} - ${ruby}/bin/ruby -e 'ENV.inspect' > env/${next.name} + ${ruby}/bin/ruby -e 'print ENV.inspect' > env/${next.name} ''} pre-installers/${next.name} '' ) "" (attrValues instantiated); diff --git a/pkgs/development/interpreters/ruby/bundler-head.nix b/pkgs/development/interpreters/ruby/bundler-head.nix index 9a05547b622..2e8cfc8cbf1 100644 --- a/pkgs/development/interpreters/ruby/bundler-head.nix +++ b/pkgs/development/interpreters/ruby/bundler-head.nix @@ -5,7 +5,7 @@ buildRubyGem { src = fetchgit { url = "https://github.com/bundler/bundler.git"; rev = "a2343c9eabf5403d8ffcbca4dea33d18a60fc157"; - sha256 = "1f0isjrn4rwak3q6sbs6v6gqhwln32gv2dbd98r902nkg9i7y5i0"; + sha256 = "1l4r55n1wzr817l225l6pm97li1mxg9icd8s51cpfihh91nkdz68"; leaveDotGit = true; }; dontPatchShebangs = true; diff --git a/pkgs/development/interpreters/ruby/monkey_patches.rb b/pkgs/development/interpreters/ruby/monkey_patches.rb index 69dbf1b5ca3..8e5ab632f74 100644 --- a/pkgs/development/interpreters/ruby/monkey_patches.rb +++ b/pkgs/development/interpreters/ruby/monkey_patches.rb @@ -1,5 +1,10 @@ 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. @@ -21,12 +26,12 @@ Bundler.module_eval do # swap out ENV def nix_with_env(env, &block) if env + old_env = ENV.to_hash begin - old_env = ENV.to_h ENV.replace(env) block.call ensure - ENV.replace old_env + ENV.replace(old_env) end else block.call @@ -131,7 +136,15 @@ Bundler::Installer.class_eval do pre_installer = "pre-installers/#{spec.name}" if File.exist?(pre_installer) system(pre_installer) + unless $?.success? + Bundler.ui.error "The pre-installer script for #{spec.name} failed!" + exit 1 + end env = eval(Bundler.read_file("env/#{spec.name}")) + 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