anchor.diff:            require 'bundler/setup'
           '';
           in stdenv.mkDerivation {
  -          name = "interactive-${name}-environment";
  +          name = "interactive-${drvName}-environment";
             nativeBuildInputs = [ wrappedRuby bundlerEnv ];
             shellHook = ''
               export OLD_IRBRC="$IRBRC"
  
positive.code: }@args:
  
  let
    importedGemset = import gemset;
    filteredGemset = (lib.filterAttrs (name: attrs:
      if (builtins.hasAttr "groups" attrs)
      then (builtins.any (gemGroup: builtins.any (group: group == gemGroup) groups) attrs.groups)
      else true
    ) importedGemset);
    applyGemConfigs = attrs:
      (if gemConfig ? "${attrs.gemName}"
      then attrs // gemConfig."${attrs.gemName}" attrs
      else attrs);
    configuredGemset = lib.flip lib.mapAttrs filteredGemset (name: attrs:
      applyGemConfigs (attrs // { inherit ruby; gemName = name; })
    );
    hasBundler = builtins.hasAttr "bundler" filteredGemset;
    bundler = if hasBundler then gems.bundler else defs.bundler.override (attrs: { inherit ruby; });
    gems = lib.flip lib.mapAttrs configuredGemset (name: attrs:
      buildRubyGem ((removeAttrs attrs ["source"]) // attrs.source // {
        inherit ruby;
        gemName = name;
        gemPath = map (gemName: gems."${gemName}") (attrs.dependencies or []);
      }));
    # We have to normalize the Gemfile.lock, otherwise bundler tries to be
    # helpful by doing so at run time, causing executables to immediately bail
    # out. Yes, I'm serious.
    confFiles = runCommand "gemfile-and-lockfile" {} ''
      mkdir -p $out
      cp ${gemfile} $out/Gemfile
      cp ${lockfile} $out/Gemfile.lock
    '';
    envPaths = lib.attrValues gems ++ lib.optional (!hasBundler) bundler;
    bundlerEnv = buildEnv {
      inherit name ignoreCollisions;
      paths = envPaths;
      pathsToLink = [ "/lib" ];
      postBuild = ''
        ${ruby}/bin/ruby ${./gen-bin-stubs.rb} \
          "${ruby}/bin/ruby" \
          "${confFiles}/Gemfile" \
          "$out/${ruby.gemPath}" \
          "${bundler}/${ruby.gemPath}" \
          ${lib.escapeShellArg envPaths} \
          ${lib.escapeShellArg groups}
      '' + lib.optionalString (postBuild != null) postBuild;
      passthru = rec {
        inherit ruby bundler meta gems;
  
        wrappedRuby = stdenv.mkDerivation {
          name = "wrapped-ruby-${name}";
          nativeBuildInputs = [ makeWrapper ];
          buildCommand = ''
            mkdir -p $out/bin
  
negative.code: , tree
  }@defs:
  
  { name ? null
  , pname ? null
  , gemdir ? null
  , gemfile ? null
  , lockfile ? null
  , gemset ? null
  , ruby ? defs.ruby
  , gemConfig ? defaultGemConfig
  , postBuild ? null
  , document ? []
  , meta ? {}
  