Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions pkgs/development/ruby-modules/bundled-common/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{ stdenv, runCommand, ruby, lib, rsync
{ stdenv
, lib
, buildPackages
, runCommand
, ruby
, defaultGemConfig, buildRubyGem, buildEnv
, makeBinaryWrapper
, bundler
Expand Down Expand Up @@ -190,7 +194,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"
''
Expand Down
17 changes: 15 additions & 2 deletions pkgs/development/ruby-modules/bundled-common/functions.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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}" \
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env ruby
require 'rbconfig'
require 'rubygems'
require 'rubygems/specification'
Expand Down
9 changes: 5 additions & 4 deletions pkgs/development/ruby-modules/bundler-env/default.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{ ruby, lib, callPackage, defaultGemConfig, buildEnv, runCommand
, bundler, rsync
, buildPackages
, bundler
}@defs:

{ name ? null
Expand All @@ -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; });

Expand Down Expand Up @@ -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;
Expand All @@ -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"
''
Expand Down
10 changes: 10 additions & 0 deletions pkgs/development/ruby-modules/gem/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,16 @@ 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
patchShebangs --update --host $out/${ruby.gemPath}/bin
runHook postFixup
'';

propagatedBuildInputs = gemPath ++ propagatedBuildInputs;
propagatedUserEnvPkgs = gemPath ++ propagatedUserEnvPkgs;

Expand Down