Skip to content

Commit

Permalink
ruby: Fix withPackages on darwin with makeBinaryWrapper
Browse files Browse the repository at this point in the history
See also NixOS#161298
  • Loading branch information
amarshall committed Jan 11, 2023
1 parent 8515585 commit baf1f12
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
6 changes: 3 additions & 3 deletions pkgs/development/interpreters/ruby/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
, zlib, gdbm, ncurses, readline, groff, libyaml, libffi, jemalloc, autoreconfHook, bison
, autoconf, libiconv, libobjc, libunwind, Foundation
, buildEnv, bundler, bundix
, makeWrapper, buildRubyGem, defaultGemConfig, removeReferencesTo
, makeBinaryWrapper, buildRubyGem, defaultGemConfig, removeReferencesTo
, openssl, openssl_1_1
} @ args:

Expand Down Expand Up @@ -47,7 +47,7 @@ let
, autoreconfHook, bison, autoconf
, buildEnv, bundler, bundix
, libiconv, libobjc, libunwind, Foundation
, makeWrapper, buildRubyGem, defaultGemConfig
, makeBinaryWrapper, buildRubyGem, defaultGemConfig
, baseRuby ? buildPackages.ruby_3_1.override {
useRailsExpress = false;
docSupport = false;
Expand Down Expand Up @@ -245,7 +245,7 @@ let
};

inherit (import ../../ruby-modules/with-packages {
inherit lib stdenv makeWrapper buildRubyGem buildEnv;
inherit lib stdenv makeBinaryWrapper buildRubyGem buildEnv;
gemConfig = defaultGemConfig;
ruby = self;
}) withPackages buildGems gems;
Expand Down
6 changes: 3 additions & 3 deletions pkgs/development/ruby-modules/with-packages/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ stdenv, lib, buildEnv, buildRubyGem, ruby, gemConfig, makeWrapper }:
{ stdenv, lib, buildEnv, buildRubyGem, ruby, gemConfig, makeBinaryWrapper }:

/*
Example usage:
Expand Down Expand Up @@ -43,7 +43,7 @@ let

wrappedRuby = stdenv.mkDerivation {
name = "wrapped-${ruby.name}";
nativeBuildInputs = [ makeWrapper ];
nativeBuildInputs = [ makeBinaryWrapper ];
buildCommand = ''
mkdir -p $out/bin
for i in ${ruby}/bin/*; do
Expand All @@ -54,7 +54,7 @@ let

in stdenv.mkDerivation {
name = "${ruby.name}-with-packages";
nativeBuildInputs = [ makeWrapper ];
nativeBuildInputs = [ makeBinaryWrapper ];
buildInputs = [ selected ruby ];

dontUnpack = true;
Expand Down
18 changes: 17 additions & 1 deletion pkgs/development/ruby-modules/with-packages/test.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,22 @@ let
pkgs.ruby.gems) //
(import ./require_exceptions.nix);

testWrapper = ruby: stdenv.mkDerivation {
name = "test-wrappedRuby-${ruby.name}";
buildInputs = [ ((ruby.withPackages (ps: [ ])).wrappedRuby) ];
buildCommand = ''
cat <<'EOF' > test-ruby
#!/usr/bin/env ruby
puts RUBY_VERSION
EOF
chmod +x test-ruby
patchShebangs test-ruby
[[ $(./test-ruby) = $(${ruby}/bin/ruby test-ruby) ]]
touch $out
'';
};

tests = ruby:
lib.mapAttrs (name: gem:
let
Expand All @@ -39,7 +55,7 @@ let
in
stdenv.mkDerivation {
name = "test-all-ruby-gems";
buildInputs = builtins.foldl' (sum: ruby: sum ++ ( builtins.attrValues (tests ruby) )) [] rubyVersions;
buildInputs = builtins.foldl' (sum: ruby: sum ++ [ (testWrapper ruby) ] ++ ( builtins.attrValues (tests ruby) )) [] rubyVersions;
buildCommand = ''
touch $out
'';
Expand Down

0 comments on commit baf1f12

Please sign in to comment.