3 require 'rubygems/specification'
11 bundler_path = ARGV[3]
13 groups = ARGV[5].split
16 FileUtils.mkdir_p("#{out}/bin")
18 next unless File.directory?("#{path}/nix-support/gem-meta")
20 name = File.read("#{path}/nix-support/gem-meta/name")
21 executables = File.read("#{path}/nix-support/gem-meta/executables")
22 .force_encoding('UTF-8').split
23 executables.each do |exe|
24 File.open("#{out}/bin/#{exe}", "w") do |f|
28 # This file was generated by Nix.
30 # The application '#{exe}' is installed as part of a gem, and
31 # this file is here to facilitate running it.
34 ENV["BUNDLE_GEMFILE"] = #{gemfile.dump}
35 ENV.delete 'BUNDLE_PATH'
36 ENV['BUNDLE_FROZEN'] = '1'
37 ENV['BUNDLE_IGNORE_CONFIG'] = '1'
39 Gem.paths = { 'GEM_HOME' => #{bundle_path.dump} }
41 $LOAD_PATH.unshift #{File.join(bundler_path, "/lib").dump}
44 # Monkey-patch out the check that Bundler performs to determine
45 # whether the bundler env is writable. It's not writable, even for
46 # root! And for this use of Bundler, it shouldn't be necessary since
47 # we're not trying to perform any package management operations, only
48 # produce a Gem path. Thus, we replace it with a method that will
49 # always return false, to squelch a warning from Bundler saying that
50 # sudo may be required.
58 Bundler.setup(#{groups.map(&:dump).join(', ')})
60 load Gem.bin_path(#{name.dump}, #{exe.dump})
62 FileUtils.chmod("+x", "#{out}/bin/#{exe}")