Overriding bundler version in bundlerEnv (with a possible fix?)

I’ve been trying to get bundlerEnv to use a newer version of bundler, and have been going down many rabbitholes.

Here’s the bundler.nix that I’d like to use in place of the older bundler version (2.1.4)

{ buildRubyGem, makeWrapper, ruby, coreutils }:
buildRubyGem rec {
  inherit ruby;
  name = "${gemName}-${version}";
  gemName = "bundler";
  version = "2.2.11";
  source.sha256 = "1izx6wsjdm6mnbxazgz1z5qbhwrrisbq0np2nmx4ij6lrqjy18jf";
  dontPatchShebangs = true;

  postFixup = ''
    sed -i -e "s/activate_bin_path/bin_path/g" $out/bin/bundle

    # silence an annoying warning about sudo being needed
    sed -i -e '/if sudo_needed/I,+2 d' $out/lib/ruby/gems/${ruby.version.libDir}/gems/${name}/lib/bundler.rb
  '';
}

One option is to add this as an overlay to override pkgs.bundler, but that seems to cause an awful lot of rebuilds from source for any other packages that happen to use ruby.

So I’ve been trying to override it just for bundlerEnv. It sort of looks like you might just be able to use bundlerEnv.override({ bundler = newBundler }) (nixpkgs/default.nix at 11cd34cd592f917bab5f42e2b378ab329dee3bcf · NixOS/nixpkgs · GitHub) but as far as I can tell that bundler argument actually does very little. eg if you pass a bad value for bundler it still builds fine:

pkgs.bundlerEnv.override { bundler = 12345; } {
   name = "foo";
   gemset = ./gemset.nix;
}

One possible fix is to change this line: nixpkgs/default.nix at 11cd34cd592f917bab5f42e2b378ab329dee3bcf · NixOS/nixpkgs · GitHub as follows:

- basicEnv = (callPackage ../bundled-common {}) (args // { inherit pname name; mainGemName = pname; });
+ basicEnv = (callPackage ../bundled-common { inherit bundler ruby; }) (args // { inherit pname name; mainGemName = pname; });

Can anyone see a good reason that isn’t already the case? I’m basically doing the monkeys-on-typewriters approach to fixing this, I can’t say I’ve got a good understanding on what’s going on with nix/bundlerEnv.

And is there a way of using that newer version of bundler short of getting that fix upstreamed into nixpkgs?