ruby-modules: Add new url source
type
This just defers to `fetchurl` for fetching. Additionally, update the `nix-bundle-install.rb` script to handle gems installed from a path, i.e. those with a `url` source. Some parts of that script have been disabled in the `path` case that likely shouldn't be, but cause errors and aren't necessary to get `vagrant` to work.
This commit is contained in:
parent
b85c083c99
commit
0750c5aee4
@ -65,6 +65,8 @@ let
|
|||||||
inherit (attrs.source) url rev sha256 fetchSubmodules;
|
inherit (attrs.source) url rev sha256 fetchSubmodules;
|
||||||
leaveDotGit = true;
|
leaveDotGit = true;
|
||||||
}
|
}
|
||||||
|
else if type == "url" then
|
||||||
|
fetchurl attrs.source
|
||||||
else
|
else
|
||||||
throw "buildRubyGem: don't know how to build a gem of type \"${type}\""
|
throw "buildRubyGem: don't know how to build a gem of type \"${type}\""
|
||||||
);
|
);
|
||||||
@ -84,7 +86,8 @@ stdenv.mkDerivation ((builtins.removeAttrs attrs ["source"]) // {
|
|||||||
|
|
||||||
buildInputs = [
|
buildInputs = [
|
||||||
ruby makeWrapper
|
ruby makeWrapper
|
||||||
] ++ lib.optionals (type == "git") [ git bundler ]
|
] ++ lib.optionals (type == "git") [ git ]
|
||||||
|
++ lib.optionals (type != "gem") [ bundler ]
|
||||||
++ lib.optional stdenv.isDarwin darwin.libobjc
|
++ lib.optional stdenv.isDarwin darwin.libobjc
|
||||||
++ buildInputs;
|
++ buildInputs;
|
||||||
|
|
||||||
@ -159,14 +162,22 @@ stdenv.mkDerivation ((builtins.removeAttrs attrs ["source"]) // {
|
|||||||
|
|
||||||
echo "buildFlags: $buildFlags"
|
echo "buildFlags: $buildFlags"
|
||||||
|
|
||||||
|
${lib.optionalString (type == "url") ''
|
||||||
|
ruby ${./nix-bundle-install.rb} \
|
||||||
|
"path" \
|
||||||
|
'${gemName}' \
|
||||||
|
'${version}' \
|
||||||
|
'${lib.escapeShellArgs buildFlags}'
|
||||||
|
''}
|
||||||
${lib.optionalString (type == "git") ''
|
${lib.optionalString (type == "git") ''
|
||||||
ruby ${./nix-bundle-install.rb} \
|
ruby ${./nix-bundle-install.rb} \
|
||||||
${gemName} \
|
"git" \
|
||||||
${attrs.source.url} \
|
'${gemName}' \
|
||||||
${src} \
|
'${version}' \
|
||||||
${attrs.source.rev} \
|
'${lib.escapeShellArgs buildFlags}' \
|
||||||
${version} \
|
'${attrs.source.url}' \
|
||||||
${lib.escapeShellArgs buildFlags}
|
'${src}' \
|
||||||
|
'${attrs.source.rev}'
|
||||||
''}
|
''}
|
||||||
|
|
||||||
${lib.optionalString (type == "gem") ''
|
${lib.optionalString (type == "gem") ''
|
||||||
|
@ -13,31 +13,46 @@ end
|
|||||||
|
|
||||||
# Options:
|
# Options:
|
||||||
#
|
#
|
||||||
|
# type - installation type, either "git" or "path"
|
||||||
# name - the gem name
|
# name - the gem name
|
||||||
|
# version - gem version
|
||||||
|
# build-flags - build arguments
|
||||||
|
#
|
||||||
|
# Git-only options:
|
||||||
|
#
|
||||||
# uri - git repo uri
|
# uri - git repo uri
|
||||||
# repo - path to local checkout
|
# repo - path to local checkout
|
||||||
# ref - the commit hash
|
# ref - the commit hash
|
||||||
# version - gem version
|
|
||||||
# build-flags - build arguments
|
|
||||||
|
|
||||||
ruby = File.join(ENV["ruby"], "bin", RbConfig::CONFIG['ruby_install_name'])
|
ruby = File.join(ENV["ruby"], "bin", RbConfig::CONFIG['ruby_install_name'])
|
||||||
out = ENV["out"]
|
out = ENV["out"]
|
||||||
bin_dir = File.join(ENV["out"], "bin")
|
bin_dir = File.join(ENV["out"], "bin")
|
||||||
|
|
||||||
name = ARGV[0]
|
type = ARGV[0]
|
||||||
uri = ARGV[1]
|
name = ARGV[1]
|
||||||
REPO = ARGV[2]
|
version = ARGV[2]
|
||||||
ref = ARGV[3]
|
build_flags = ARGV[3]
|
||||||
version = ARGV[4]
|
if type == "git"
|
||||||
build_flags = ARGV[5]
|
uri = ARGV[4]
|
||||||
|
REPO = ARGV[5]
|
||||||
|
ref = ARGV[6]
|
||||||
|
end
|
||||||
|
|
||||||
# options to pass to bundler
|
# options to pass to bundler
|
||||||
options = {
|
options = {
|
||||||
"name" => name,
|
"name" => name,
|
||||||
"uri" => uri,
|
|
||||||
"ref" => ref,
|
|
||||||
"version" => version,
|
"version" => version,
|
||||||
}
|
}
|
||||||
|
if type == "path"
|
||||||
|
options.merge!({
|
||||||
|
"path" => Dir.pwd,
|
||||||
|
})
|
||||||
|
elsif type == "git"
|
||||||
|
options.merge!({
|
||||||
|
"uri" => uri,
|
||||||
|
"ref" => ref,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
# Monkey-patch Bundler to use our local checkout.
|
# Monkey-patch Bundler to use our local checkout.
|
||||||
# I wish we didn't have to do this, but bundler does not expose an API to do
|
# I wish we didn't have to do this, but bundler does not expose an API to do
|
||||||
@ -63,26 +78,28 @@ Bundler.module_eval do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Bundler::Source::Git.class_eval do
|
if type == "git"
|
||||||
def allow_git_ops?
|
Bundler::Source::Git.class_eval do
|
||||||
true
|
def allow_git_ops?
|
||||||
end
|
true
|
||||||
end
|
|
||||||
|
|
||||||
Bundler::Source::Git::GitProxy.class_eval do
|
|
||||||
def checkout
|
|
||||||
unless path.exist?
|
|
||||||
FileUtils.mkdir_p(path.dirname)
|
|
||||||
FileUtils.cp_r(File.join(REPO, ".git"), path)
|
|
||||||
system("chmod -R +w #{path}")
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def copy_to(destination, submodules=false)
|
Bundler::Source::Git::GitProxy.class_eval do
|
||||||
unless File.exist?(destination.join(".git"))
|
def checkout
|
||||||
FileUtils.mkdir_p(destination.dirname)
|
unless path.exist?
|
||||||
FileUtils.cp_r(REPO, destination)
|
FileUtils.mkdir_p(path.dirname)
|
||||||
system("chmod -R +w #{destination}")
|
FileUtils.cp_r(File.join(REPO, ".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(REPO, destination)
|
||||||
|
system("chmod -R +w #{destination}")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -94,7 +111,11 @@ Bundler.ui = Bundler::UI::Shell.new({"no-color" => no_color})
|
|||||||
Bundler.ui.level = "debug" if verbose
|
Bundler.ui.level = "debug" if verbose
|
||||||
|
|
||||||
# Install
|
# Install
|
||||||
source = Bundler::Source::Git.new(options)
|
if type == "git"
|
||||||
|
source = Bundler::Source::Git.new(options)
|
||||||
|
else
|
||||||
|
source = Bundler::Source::Path.new(options)
|
||||||
|
end
|
||||||
spec = source.specs.search_all(name).first
|
spec = source.specs.search_all(name).first
|
||||||
Bundler.rubygems.with_build_args [build_flags] do
|
Bundler.rubygems.with_build_args [build_flags] do
|
||||||
source.install(spec)
|
source.install(spec)
|
||||||
@ -139,8 +160,10 @@ FileUtils.ln_s(spec.loaded_from.to_s, "#{meta}/spec")
|
|||||||
File.open("#{meta}/name", "w") do |f|
|
File.open("#{meta}/name", "w") do |f|
|
||||||
f.write spec.name
|
f.write spec.name
|
||||||
end
|
end
|
||||||
File.open("#{meta}/install-path", "w") do |f|
|
if type == "git"
|
||||||
f.write source.install_path.to_s
|
File.open("#{meta}/install-path", "w") do |f|
|
||||||
|
f.write source.install_path.to_s
|
||||||
|
end
|
||||||
end
|
end
|
||||||
File.open("#{meta}/require-paths", "w") do |f|
|
File.open("#{meta}/require-paths", "w") do |f|
|
||||||
f.write spec.require_paths.join(" ")
|
f.write spec.require_paths.join(" ")
|
||||||
@ -150,8 +173,10 @@ File.open("#{meta}/executables", "w") do |f|
|
|||||||
end
|
end
|
||||||
|
|
||||||
# make the lib available during bundler/git installs
|
# make the lib available during bundler/git installs
|
||||||
File.open("#{out}/nix-support/setup-hook", "a") do |f|
|
if type == "git"
|
||||||
spec.require_paths.each do |dir|
|
File.open("#{out}/nix-support/setup-hook", "a") do |f|
|
||||||
f.puts("addToSearchPath RUBYLIB #{source.install_path}/#{dir}")
|
spec.require_paths.each do |dir|
|
||||||
|
f.puts("addToSearchPath RUBYLIB #{source.install_path}/#{dir}")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user