ruby-modules: improve cross-compilation support
This commit is contained in:
parent
77347136f6
commit
30971173ab
@ -1,4 +1,8 @@
|
|||||||
{ stdenv, runCommand, ruby, lib, rsync
|
{ stdenv
|
||||||
|
, lib
|
||||||
|
, buildPackages
|
||||||
|
, runCommand
|
||||||
|
, ruby
|
||||||
, defaultGemConfig, buildRubyGem, buildEnv
|
, defaultGemConfig, buildRubyGem, buildEnv
|
||||||
, makeBinaryWrapper
|
, makeBinaryWrapper
|
||||||
, bundler
|
, bundler
|
||||||
@ -190,7 +194,7 @@ let
|
|||||||
runCommand name' basicEnvArgs ''
|
runCommand name' basicEnvArgs ''
|
||||||
mkdir -p $out
|
mkdir -p $out
|
||||||
for i in $paths; do
|
for i in $paths; do
|
||||||
${rsync}/bin/rsync -a $i/lib $out/
|
${buildPackages.rsync}/bin/rsync -a $i/lib $out/
|
||||||
done
|
done
|
||||||
eval "$postBuild"
|
eval "$postBuild"
|
||||||
''
|
''
|
||||||
|
@ -59,8 +59,21 @@ in rec {
|
|||||||
then attrs // gemConfig.${attrs.gemName} attrs
|
then attrs // gemConfig.${attrs.gemName} attrs
|
||||||
else attrs);
|
else attrs);
|
||||||
|
|
||||||
genStubsScript = { lib, ruby, confFiles, bundler, groups, binPaths, ... }: ''
|
genStubsScript = { lib, runCommand, ruby, confFiles, bundler, groups, binPaths, ... }:
|
||||||
${ruby}/bin/ruby ${./gen-bin-stubs.rb} \
|
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" \
|
"${ruby}/bin/ruby" \
|
||||||
"${confFiles}/Gemfile" \
|
"${confFiles}/Gemfile" \
|
||||||
"$out/${ruby.gemPath}" \
|
"$out/${ruby.gemPath}" \
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
#!/usr/bin/env ruby
|
||||||
require 'rbconfig'
|
require 'rbconfig'
|
||||||
require 'rubygems'
|
require 'rubygems'
|
||||||
require 'rubygems/specification'
|
require 'rubygems/specification'
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
{ ruby, lib, callPackage, defaultGemConfig, buildEnv, runCommand
|
{ ruby, lib, callPackage, defaultGemConfig, buildEnv, runCommand
|
||||||
, bundler, rsync
|
, buildPackages
|
||||||
|
, bundler
|
||||||
}@defs:
|
}@defs:
|
||||||
|
|
||||||
{ name ? null
|
{ name ? null
|
||||||
@ -21,7 +22,7 @@
|
|||||||
}@args:
|
}@args:
|
||||||
|
|
||||||
let
|
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; });
|
basicEnv = (callPackage ../bundled-common { inherit bundler; }) (args // { inherit pname name; mainGemName = pname; });
|
||||||
|
|
||||||
@ -51,7 +52,7 @@ in
|
|||||||
pathsToLink = [ "/lib" ];
|
pathsToLink = [ "/lib" ];
|
||||||
|
|
||||||
postBuild = genStubsScript {
|
postBuild = genStubsScript {
|
||||||
inherit lib ruby bundler groups;
|
inherit lib runCommand ruby bundler groups;
|
||||||
confFiles = basicEnv.confFiles;
|
confFiles = basicEnv.confFiles;
|
||||||
binPaths = [ basicEnv.gems.${pname} ];
|
binPaths = [ basicEnv.gems.${pname} ];
|
||||||
} + lib.optionalString (postBuild != null) postBuild;
|
} + lib.optionalString (postBuild != null) postBuild;
|
||||||
@ -67,7 +68,7 @@ in
|
|||||||
runCommand basicEnv.name bundlerEnvArgs ''
|
runCommand basicEnv.name bundlerEnvArgs ''
|
||||||
mkdir -p $out
|
mkdir -p $out
|
||||||
for i in $paths; do
|
for i in $paths; do
|
||||||
${rsync}/bin/rsync -a $i/lib $out/
|
${buildPackages.rsync}/bin/rsync -a $i/lib $out/
|
||||||
done
|
done
|
||||||
eval "$postBuild"
|
eval "$postBuild"
|
||||||
''
|
''
|
||||||
|
@ -252,6 +252,16 @@ stdenv.mkDerivation ((builtins.removeAttrs attrs ["source"]) // {
|
|||||||
runHook postInstall
|
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
|
||||||
|
patchShebangs --update --host $out/${ruby.gemPath}/bin
|
||||||
|
runHook postFixup
|
||||||
|
'';
|
||||||
|
|
||||||
propagatedBuildInputs = gemPath ++ propagatedBuildInputs;
|
propagatedBuildInputs = gemPath ++ propagatedBuildInputs;
|
||||||
propagatedUserEnvPkgs = gemPath ++ propagatedUserEnvPkgs;
|
propagatedUserEnvPkgs = gemPath ++ propagatedUserEnvPkgs;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user