mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-22 06:53:01 +00:00
Merge pull request #270242 from tie/ruby-cross
ruby-modules: improve cross-compilation support
This commit is contained in:
commit
897e070df7
@ -1,4 +1,8 @@
|
||||
{ stdenv, runCommand, ruby, lib, rsync
|
||||
{ stdenv
|
||||
, lib
|
||||
, buildPackages
|
||||
, runCommand
|
||||
, ruby
|
||||
, defaultGemConfig, buildRubyGem, buildEnv
|
||||
, makeBinaryWrapper
|
||||
, bundler
|
||||
@ -191,7 +195,7 @@ let
|
||||
runCommand name' basicEnvArgs ''
|
||||
mkdir -p $out
|
||||
for i in $paths; do
|
||||
${rsync}/bin/rsync -a $i/lib $out/
|
||||
${buildPackages.rsync}/bin/rsync -a $i/lib $out/
|
||||
done
|
||||
eval "$postBuild"
|
||||
''
|
||||
|
@ -59,8 +59,21 @@ in rec {
|
||||
then attrs // gemConfig.${attrs.gemName} attrs
|
||||
else attrs);
|
||||
|
||||
genStubsScript = { lib, ruby, confFiles, bundler, groups, binPaths, ... }: ''
|
||||
${ruby}/bin/ruby ${./gen-bin-stubs.rb} \
|
||||
genStubsScript = { lib, runCommand, ruby, confFiles, bundler, groups, binPaths, ... }:
|
||||
let
|
||||
genStubsScript = runCommand "gen-bin-stubs"
|
||||
{
|
||||
strictDeps = true;
|
||||
nativeBuildInputs = [ ruby ];
|
||||
}
|
||||
''
|
||||
cp ${./gen-bin-stubs.rb} $out
|
||||
chmod +x $out
|
||||
patchShebangs --build $out
|
||||
'';
|
||||
in
|
||||
''
|
||||
${genStubsScript} \
|
||||
"${ruby}/bin/ruby" \
|
||||
"${confFiles}/Gemfile" \
|
||||
"$out/${ruby.gemPath}" \
|
||||
|
@ -1,3 +1,4 @@
|
||||
#!/usr/bin/env ruby
|
||||
require 'rbconfig'
|
||||
require 'rubygems'
|
||||
require 'rubygems/specification'
|
||||
|
@ -1,5 +1,6 @@
|
||||
{ ruby, lib, callPackage, defaultGemConfig, buildEnv, runCommand
|
||||
, bundler, rsync
|
||||
, buildPackages
|
||||
, bundler
|
||||
}@defs:
|
||||
|
||||
{ name ? null
|
||||
@ -21,7 +22,7 @@
|
||||
}@args:
|
||||
|
||||
let
|
||||
inherit (import ../bundled-common/functions.nix {inherit lib ruby gemConfig groups; }) genStubsScript;
|
||||
inherit (import ../bundled-common/functions.nix { inherit lib ruby gemConfig groups; }) genStubsScript;
|
||||
|
||||
basicEnv = (callPackage ../bundled-common { inherit bundler; }) (args // { inherit pname name; mainGemName = pname; });
|
||||
|
||||
@ -51,7 +52,7 @@ in
|
||||
pathsToLink = [ "/lib" ];
|
||||
|
||||
postBuild = genStubsScript {
|
||||
inherit lib ruby bundler groups;
|
||||
inherit lib runCommand ruby bundler groups;
|
||||
confFiles = basicEnv.confFiles;
|
||||
binPaths = [ basicEnv.gems.${pname} ];
|
||||
} + lib.optionalString (postBuild != null) postBuild;
|
||||
@ -67,7 +68,7 @@ in
|
||||
runCommand basicEnv.name bundlerEnvArgs ''
|
||||
mkdir -p $out
|
||||
for i in $paths; do
|
||||
${rsync}/bin/rsync -a $i/lib $out/
|
||||
${buildPackages.rsync}/bin/rsync -a $i/lib $out/
|
||||
done
|
||||
eval "$postBuild"
|
||||
''
|
||||
|
@ -254,6 +254,18 @@ stdenv.mkDerivation ((builtins.removeAttrs attrs ["source"]) // {
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
# For Ruby-generated binstubs, shebang paths are already in Nix store but for
|
||||
# ruby used to build the package. Update them to match the host system. Note
|
||||
# that patchShebangsAuto ignores scripts where shebang line is already in Nix
|
||||
# store.
|
||||
fixupPhase = attrs.fixupPhase or ''
|
||||
runHook preFixup
|
||||
if [[ -d $out/${ruby.gemPath}/bin ]]; then
|
||||
patchShebangs --update --host $out/${ruby.gemPath}/bin
|
||||
fi
|
||||
runHook postFixup
|
||||
'';
|
||||
|
||||
propagatedBuildInputs = gemPath ++ propagatedBuildInputs;
|
||||
propagatedUserEnvPkgs = gemPath ++ propagatedUserEnvPkgs;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user