diff --git a/pkgs/development/ruby-modules/bundled-common/functions.nix b/pkgs/development/ruby-modules/bundled-common/functions.nix index 35307a3fbd933..e4eff265643ba 100644 --- a/pkgs/development/ruby-modules/bundled-common/functions.nix +++ b/pkgs/development/ruby-modules/bundled-common/functions.nix @@ -83,11 +83,19 @@ in rec { }; in res; - composeGemAttrs = ruby: gems: name: attrs: ((removeAttrs attrs ["platforms"]) // { - inherit ruby; - inherit (attrs.source) type; - source = removeAttrs attrs.source ["type"]; - gemName = name; - gemPath = map (gemName: gems.${gemName}) (attrs.dependencies or []); - }); + composeGemAttrs = ruby: gems: name: attrs: + let matchingSource = lib.findFirst (p: + if lib.hasPrefix "arm64-darwin" p.platform then ruby.stdenv.hostPlatform.system == "aarch64-darwin" + else if lib.hasPrefix "x86_64-darwin" p.platform then ruby.stdenv.hostPlatform.system == "x86_64-darwin" + else if p.platform == "x86_64-linux" then ruby.stdenv.hostPlatform.system == "x86_64-linux" + else false + ) attrs.source (attrs.nativeSources or []); + in ((removeAttrs attrs ["platforms" "nativeSources"]) // { + inherit ruby; + inherit (matchingSource) type; + source = removeAttrs matchingSource ["type" "platform"]; + gemName = name; + gemPath = map (gemName: gems.${gemName}) (attrs.dependencies or []); + version = if (matchingSource.platform or "ruby") == "ruby" then attrs.version else "${attrs.version}-${matchingSource.platform}"; + }); }