From 51aeaf7a61d7ae1b7b582c25ef35778ce223a2ad Mon Sep 17 00:00:00 2001 From: MidAutumnMoon Date: Tue, 13 Feb 2024 14:34:09 +0800 Subject: [PATCH] ruby: replace rec {} with finalAttrs & make overriding possible Without this change, use overrideAttrs on Ruby won't change the instance used by Gems, making it very difficult to build a custom Ruby (e.g. add devdoc). --- .../development/interpreters/ruby/default.nix | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/pkgs/development/interpreters/ruby/default.nix b/pkgs/development/interpreters/ruby/default.nix index 781b3273e3a9..c14cb4648e35 100644 --- a/pkgs/development/interpreters/ruby/default.nix +++ b/pkgs/development/interpreters/ruby/default.nix @@ -24,7 +24,7 @@ let atLeast32 = lib.versionAtLeast ver.majMin "3.2"; # https://github.com/ruby/ruby/blob/v3_2_2/yjit.h#L21 yjitSupported = atLeast32 && (stdenv.hostPlatform.isx86_64 || (!stdenv.hostPlatform.isWindows && stdenv.hostPlatform.isAarch64)); - self = lib.makeOverridable ( + rubyDrv = lib.makeOverridable ( { stdenv, buildPackages, lib , fetchurl, fetchpatch, fetchFromSavannah, fetchFromGitHub , rubygemsSupport ? true @@ -58,7 +58,7 @@ let } , useBaseRuby ? stdenv.hostPlatform != stdenv.buildPlatform }: - stdenv.mkDerivation rec { + stdenv.mkDerivation ( finalAttrs: { pname = "ruby"; inherit version; @@ -123,8 +123,8 @@ let cargoRoot = opString yjitSupport "yjit"; cargoDeps = if yjitSupport then rustPlatform.fetchCargoTarball { - inherit src; - sourceRoot = "${pname}-${version}/${cargoRoot}"; + inherit (finalAttrs) src; + sourceRoot = "${finalAttrs.pname}-${version}/${finalAttrs.cargoRoot}"; hash = cargoHash; } else null; @@ -175,8 +175,8 @@ let preInstall = '' # Ruby installs gems here itself now. - mkdir -pv "$out/${passthru.gemPath}" - export GEM_HOME="$out/${passthru.gemPath}" + mkdir -pv "$out/${finalAttrs.passthru.gemPath}" + export GEM_HOME="$out/${finalAttrs.passthru.gemPath}" ''; installFlags = lib.optional docSupport "install-doc"; @@ -205,16 +205,16 @@ let sed -i 's/CONFIG\["CC"\] = "\(.*\)"/CONFIG["CC"] = if ENV["CC"].nil? || ENV["CC"].empty? then "\1" else ENV["CC"] end/' "$rbConfig" # Remove unnecessary external intermediate files created by gems - extMakefiles=$(find $out/${passthru.gemPath} -name Makefile) + extMakefiles=$(find $out/${finalAttrs.passthru.gemPath} -name Makefile) for makefile in $extMakefiles; do make -C "$(dirname "$makefile")" distclean done - find "$out/${passthru.gemPath}" \( -name gem_make.out -o -name mkmf.log \) -delete + find "$out/${finalAttrs.passthru.gemPath}" \( -name gem_make.out -o -name mkmf.log \) -delete # Bundler tries to create this directory mkdir -p $out/nix-support cat > $out/nix-support/setup-hook <