From 6077061403503589d225fc0a51a514800517d813 Mon Sep 17 00:00:00 2001 From: Animesh Sahu Date: Thu, 15 Jun 2023 17:15:23 +0530 Subject: [PATCH] nixos/ruby-modules: proper treatment to ruby modules of type git/url --- .../ruby-modules/bundled-common/default.nix | 5 +++-- pkgs/development/ruby-modules/bundler-app/default.nix | 5 ++++- pkgs/development/ruby-modules/gem/default.nix | 11 ++++++++++- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/pkgs/development/ruby-modules/bundled-common/default.nix b/pkgs/development/ruby-modules/bundled-common/default.nix index aa903a5637c0..b18248c7d61b 100644 --- a/pkgs/development/ruby-modules/bundled-common/default.nix +++ b/pkgs/development/ruby-modules/bundled-common/default.nix @@ -56,9 +56,9 @@ let else let gem = gems.${pname}; - version = gem.version; + suffix = gem.suffix; in - "${pname}-${version}"; + "${pname}-${suffix}"; pname' = if pname != null then pname @@ -118,6 +118,7 @@ let passthru = rec { inherit ruby bundler gems confFiles envPaths; + inherit (gems.${pname}) gemType; wrappedRuby = stdenv.mkDerivation { name = "wrapped-ruby-${pname'}"; diff --git a/pkgs/development/ruby-modules/bundler-app/default.nix b/pkgs/development/ruby-modules/bundler-app/default.nix index 5bb9e47cf5a6..01e90ba53f1f 100644 --- a/pkgs/development/ruby-modules/bundler-app/default.nix +++ b/pkgs/development/ruby-modules/bundler-app/default.nix @@ -68,7 +68,10 @@ in ${lib.optionalString installManpages '' for section in {1..9}; do mandir="$out/share/man/man$section" - find -L ${basicEnv}/${ruby.gemPath}/gems/${basicEnv.name} \( -wholename "*/man/*.$section" -o -wholename "*/man/man$section/*.$section" \) -print -execdir mkdir -p $mandir \; -execdir cp '{}' $mandir \; + + # See: https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/ruby-modules/gem/default.nix#L184-L200 + # See: https://github.com/rubygems/rubygems/blob/7a7b234721c375874b7e22b1c5b14925b943f04e/bundler/lib/bundler.rb#L285-L291 + find -L ${basicEnv}/${ruby.gemPath}/${lib.optionalString (basicEnv.gemType == "git" || basicEnv.gemType == "url") "bundler/"}gems/${basicEnv.name} \( -wholename "*/man/*.$section" -o -wholename "*/man/man$section/*.$section" \) -print -execdir mkdir -p $mandir \; -execdir cp '{}' $mandir \; done ''} '' diff --git a/pkgs/development/ruby-modules/gem/default.nix b/pkgs/development/ruby-modules/gem/default.nix index 7105663413a2..b33758486eed 100644 --- a/pkgs/development/ruby-modules/gem/default.nix +++ b/pkgs/development/ruby-modules/gem/default.nix @@ -75,6 +75,14 @@ let else throw "buildRubyGem: don't know how to build a gem of type \"${type}\"" ); + + # See: https://github.com/rubygems/rubygems/blob/7a7b234721c375874b7e22b1c5b14925b943f04e/bundler/lib/bundler/source/git.rb#L103 + suffix = + if type == "git" then + builtins.substring 0 12 attrs.source.rev + else + version; + documentFlag = if document == [] then "-N" @@ -86,6 +94,7 @@ stdenv.mkDerivation ((builtins.removeAttrs attrs ["source"]) // { inherit ruby; inherit dontBuild; inherit dontStrip; + inherit suffix; gemType = type; nativeBuildInputs = [ @@ -100,7 +109,7 @@ stdenv.mkDerivation ((builtins.removeAttrs attrs ["source"]) // { ++ buildInputs; #name = builtins.trace (attrs.name or "no attr.name" ) "${namePrefix}${gemName}-${version}"; - name = attrs.name or "${namePrefix}${gemName}-${version}"; + name = attrs.name or "${namePrefix}${gemName}-${suffix}"; inherit src;