diff options
author | Charles Strahan <charles.c.strahan@gmail.com> | 2015-01-20 01:07:55 -0500 |
---|---|---|
committer | Charles Strahan <charles.c.strahan@gmail.com> | 2015-01-20 01:07:55 -0500 |
commit | 221509b0a6bd418b14e9b2bf7c9c46646b54d6ee (patch) | |
tree | 7f6fbce0be6c28454a3d9388cae9c9dfd3954496 /pkgs/development/interpreters/ruby/monkey_patches.rb | |
parent | bf16d03075bbfbb7078f396cec6a782b57cc12ae (diff) | |
download | nixpkgs-221509b0a6bd418b14e9b2bf7c9c46646b54d6ee.tar nixpkgs-221509b0a6bd418b14e9b2bf7c9c46646b54d6ee.tar.gz nixpkgs-221509b0a6bd418b14e9b2bf7c9c46646b54d6ee.tar.bz2 nixpkgs-221509b0a6bd418b14e9b2bf7c9c46646b54d6ee.tar.lz nixpkgs-221509b0a6bd418b14e9b2bf7c9c46646b54d6ee.tar.xz nixpkgs-221509b0a6bd418b14e9b2bf7c9c46646b54d6ee.tar.zst nixpkgs-221509b0a6bd418b14e9b2bf7c9c46646b54d6ee.zip |
ruby: refactoring, and package bundix
Diffstat (limited to 'pkgs/development/interpreters/ruby/monkey_patches.rb')
-rw-r--r-- | pkgs/development/interpreters/ruby/monkey_patches.rb | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/pkgs/development/interpreters/ruby/monkey_patches.rb b/pkgs/development/interpreters/ruby/monkey_patches.rb index 694a199a610..6c896861ca6 100644 --- a/pkgs/development/interpreters/ruby/monkey_patches.rb +++ b/pkgs/development/interpreters/ruby/monkey_patches.rb @@ -95,6 +95,46 @@ Bundler::Source::Rubygems.class_eval do end end +Bundler::Installer.class_eval do + 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. # @@ -122,7 +162,7 @@ Gem::Installer.class_eval do # this file is here to facilitate running it. # -old_gemfile = ENV["BUNDLE_GEMFILE"] +old_gemfile = ENV["BUNDLE_GEMFILE"] old_gem_home = ENV["GEM_HOME"] old_gem_path = ENV["GEM_PATH"] |