1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-02-16 15:58:36 +00:00

ruby: make buildInputs work

This commit is contained in:
Charles Strahan 2015-01-20 22:20:28 -05:00
parent dfc225d143
commit 7d8b2f0d60
3 changed files with 21 additions and 5 deletions

View file

@ -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);

View file

@ -5,7 +5,7 @@ buildRubyGem {
src = fetchgit {
url = "https://github.com/bundler/bundler.git";
rev = "a2343c9eabf5403d8ffcbca4dea33d18a60fc157";
sha256 = "1f0isjrn4rwak3q6sbs6v6gqhwln32gv2dbd98r902nkg9i7y5i0";
sha256 = "1l4r55n1wzr817l225l6pm97li1mxg9icd8s51cpfihh91nkdz68";
leaveDotGit = true;
};
dontPatchShebangs = true;

View file

@ -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