From baf1f1293b289ce53d9b660465cd68e1a3e00b96 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Wed, 11 Jan 2023 10:20:40 -0500 Subject: [PATCH] ruby: Fix withPackages on darwin with makeBinaryWrapper See also https://github.com/NixOS/nixpkgs/pull/161298 --- pkgs/development/interpreters/ruby/default.nix | 6 +++--- .../ruby-modules/with-packages/default.nix | 6 +++--- .../ruby-modules/with-packages/test.nix | 18 +++++++++++++++++- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/pkgs/development/interpreters/ruby/default.nix b/pkgs/development/interpreters/ruby/default.nix index 04ed31bbf3aa7..43d29d1d0cc6c 100644 --- a/pkgs/development/interpreters/ruby/default.nix +++ b/pkgs/development/interpreters/ruby/default.nix @@ -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: @@ -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; @@ -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; diff --git a/pkgs/development/ruby-modules/with-packages/default.nix b/pkgs/development/ruby-modules/with-packages/default.nix index 5be820b60e300..31573bce499fc 100644 --- a/pkgs/development/ruby-modules/with-packages/default.nix +++ b/pkgs/development/ruby-modules/with-packages/default.nix @@ -1,4 +1,4 @@ -{ stdenv, lib, buildEnv, buildRubyGem, ruby, gemConfig, makeWrapper }: +{ stdenv, lib, buildEnv, buildRubyGem, ruby, gemConfig, makeBinaryWrapper }: /* Example usage: @@ -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 @@ -54,7 +54,7 @@ let in stdenv.mkDerivation { name = "${ruby.name}-with-packages"; - nativeBuildInputs = [ makeWrapper ]; + nativeBuildInputs = [ makeBinaryWrapper ]; buildInputs = [ selected ruby ]; dontUnpack = true; diff --git a/pkgs/development/ruby-modules/with-packages/test.nix b/pkgs/development/ruby-modules/with-packages/test.nix index ca2934b6f61c9..be652747c4699 100644 --- a/pkgs/development/ruby-modules/with-packages/test.nix +++ b/pkgs/development/ruby-modules/with-packages/test.nix @@ -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 @@ -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 '';