Merge pull request #270286 from ajs124/ruby_ossl11_cleanup

ruby_2_7: remove
This commit is contained in:
Mario Rodas 2024-01-02 18:37:18 -05:00 committed by GitHub
commit 7f0a64976d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 10 additions and 130 deletions

View File

@ -2,13 +2,13 @@
## Using Ruby {#using-ruby}
Several versions of Ruby interpreters are available on Nix, as well as over 250 gems and many applications written in Ruby. The attribute `ruby` refers to the default Ruby interpreter, which is currently MRI 2.6. It's also possible to refer to specific versions, e.g. `ruby_2_y`, `jruby`, or `mruby`.
Several versions of Ruby interpreters are available on Nix, as well as over 250 gems and many applications written in Ruby. The attribute `ruby` refers to the default Ruby interpreter, which is currently MRI 3.1. It's also possible to refer to specific versions, e.g. `ruby_3_y`, `jruby`, or `mruby`.
In the Nixpkgs tree, Ruby packages can be found throughout, depending on what they do, and are called from the main package set. Ruby gems, however are separate sets, and there's one default set for each interpreter (currently MRI only).
There are two main approaches for using Ruby with gems. One is to use a specifically locked `Gemfile` for an application that has very strict dependencies. The other is to depend on the common gems, which we'll explain further down, and rely on them being updated regularly.
The interpreters have common attributes, namely `gems`, and `withPackages`. So you can refer to `ruby.gems.nokogiri`, or `ruby_2_7.gems.nokogiri` to get the Nokogiri gem already compiled and ready to use.
The interpreters have common attributes, namely `gems`, and `withPackages`. So you can refer to `ruby.gems.nokogiri`, or `ruby_3_2.gems.nokogiri` to get the Nokogiri gem already compiled and ready to use.
Since not all gems have executables like `nokogiri`, it's usually more convenient to use the `withPackages` function like this: `ruby.withPackages (p: with p; [ nokogiri ])`. This will also make sure that the Ruby in your environment will be able to find the gem and it can be used in your Ruby code (for example via `ruby` or `irb` executables) via `require "nokogiri"` as usual.
@ -33,7 +33,7 @@ Again, it's possible to launch the interpreter from the shell. The Ruby interpre
#### Load Ruby environment from `.nix` expression {#load-ruby-environment-from-.nix-expression}
As explained [in the `nix-shell` section](https://nixos.org/manual/nix/stable/command-ref/nix-shell) of the Nix manual, `nix-shell` can also load an expression from a `.nix` file.
Say we want to have Ruby 2.6, `nokogori`, and `pry`. Consider a `shell.nix` file with:
Say we want to have Ruby, `nokogori`, and `pry`. Consider a `shell.nix` file with:
```nix
with import <nixpkgs> {};
@ -114,7 +114,7 @@ With this file in your directory, you can run `nix-shell` to build and use the g
The `bundlerEnv` is a wrapper over all the gems in your gemset. This means that all the `/lib` and `/bin` directories will be available, and the executables of all gems (even of indirect dependencies) will end up in your `$PATH`. The `wrappedRuby` provides you with all executables that come with Ruby itself, but wrapped so they can easily find the gems in your gemset.
One common issue that you might have is that you have Ruby 2.6, but also `bundler` in your gemset. That leads to a conflict for `/bin/bundle` and `/bin/bundler`. You can resolve this by wrapping either your Ruby or your gems in a `lowPrio` call. So in order to give the `bundler` from your gemset priority, it would be used like this:
One common issue that you might have is that you have Ruby, but also `bundler` in your gemset. That leads to a conflict for `/bin/bundle` and `/bin/bundler`. You can resolve this by wrapping either your Ruby or your gems in a `lowPrio` call. So in order to give the `bundler` from your gemset priority, it would be used like this:
```nix
# ...

View File

@ -53,7 +53,7 @@ in
enable = mkEnableOption (lib.mdDoc "Redmine");
package = mkPackageOption pkgs "redmine" {
example = "redmine.override { ruby = pkgs.ruby_2_7; }";
example = "redmine.override { ruby = pkgs.ruby_3_2; }";
};
user = mkOption {

View File

@ -4,7 +4,7 @@
, autoconf, libiconv, libobjc, libunwind, Foundation
, buildEnv, bundler, bundix, cargo, rustPlatform, rustc
, makeBinaryWrapper, buildRubyGem, defaultGemConfig, removeReferencesTo
, openssl, openssl_1_1
, openssl
, linuxPackages, libsystemtap
} @ args:
@ -20,7 +20,6 @@ let
generic = { version, hash, cargoHash ? null }: let
ver = version;
atLeast30 = lib.versionAtLeast ver.majMin "3.0";
atLeast31 = lib.versionAtLeast ver.majMin "3.1";
atLeast32 = lib.versionAtLeast ver.majMin "3.2";
# https://github.com/ruby/ruby/blob/v3_2_2/yjit.h#L21
@ -30,7 +29,7 @@ let
, fetchurl, fetchpatch, fetchFromSavannah, fetchFromGitHub
, rubygemsSupport ? true
, zlib, zlibSupport ? true
, openssl, openssl_1_1, opensslSupport ? true
, openssl, opensslSupport ? true
, gdbm, gdbmSupport ? true
, ncurses, readline, cursesSupport ? true
, groff, docSupport ? true
@ -84,8 +83,7 @@ let
++ (op fiddleSupport libffi)
++ (ops cursesSupport [ ncurses readline ])
++ (op zlibSupport zlib)
++ (op (atLeast30 && opensslSupport) openssl)
++ (op (!atLeast30 && opensslSupport) openssl_1_1)
++ (op opensslSupport openssl)
++ (op gdbmSupport gdbm)
++ (op yamlSupport libyaml)
# Looks like ruby fails to build on darwin without readline even if curses
@ -103,7 +101,7 @@ let
enableParallelInstalling = false;
patches = op (lib.versionOlder ver.majMin "3.1") ./do-not-regenerate-revision.h.patch
++ op (atLeast30 && useBaseRuby) (
++ op useBaseRuby (
if atLeast32 then ./do-not-update-gems-baseruby-3.2.patch
else ./do-not-update-gems-baseruby.patch
)
@ -114,21 +112,6 @@ let
hash = "sha256-43hI9L6bXfeujgmgKFVmiWhg7OXvshPCCtQ4TxqK1zk=";
})
]
++ ops (!atLeast30 && rubygemsSupport) [
# We upgrade rubygems to a version that isn't compatible with the
# ruby 2.7 installer. Backport the upstream fix.
./rbinstall-new-rubygems-compat.patch
# Ruby prior to 3.0 has a bug the installer (tools/rbinstall.rb) but
# the resulting error was swallowed. Newer rubygems no longer swallows
# this error. We upgrade rubygems when rubygemsSupport is enabled, so
# we have to fix this bug to prevent the install step from failing.
# See https://github.com/ruby/ruby/pull/2930
(fetchpatch {
url = "https://github.com/ruby/ruby/commit/261d8dd20afd26feb05f00a560abd99227269c1c.patch";
hash = "sha256-HqfaevMYuIVOsdEr+CnjnUqr2IrH5fkW2uKzzoqIMXM=";
})
]
++ ops atLeast31 [
# When using a baseruby, ruby always sets "libdir" to the build
# directory, which nix rejects due to a reference in to /build/ in
@ -155,10 +138,6 @@ let
sed -i configure.ac -e '/config.guess/d'
cp --remove-destination ${config}/config.guess tool/
cp --remove-destination ${config}/config.sub tool/
'' + opString (!atLeast30) ''
# Make the build reproducible for ruby <= 2.7
# See https://github.com/ruby/io-console/commit/679a941d05d869f5e575730f6581c027203b7b26#diff-d8422f096931c58d4463e2489f62a228b0f24f0492950ba88c8c89a0d741cfe6
sed -i ext/io/console/io-console.gemspec -e '/s\.date/d'
'';
configureFlags = [
@ -316,11 +295,6 @@ in {
mkRubyVersion = rubyVersion;
mkRuby = generic;
ruby_2_7 = generic {
version = rubyVersion "2" "7" "8" "";
hash = "sha256-wtq2PLyPKgVSYQitQZ76Y6Z+1AdNu8+fwrHKZky0W6A=";
};
ruby_3_1 = generic {
version = rubyVersion "3" "1" "4" "";
hash = "sha256-o9VYeaDfqx1xQf3xDSKgfb+OXNxEFdob3gYSfVzDx7Y=";

View File

@ -1,87 +0,0 @@
From 8e85d27f9ccfe152fc1b891c19f125915a907493 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <vondruch@redhat.com>
Date: Tue, 1 Oct 2019 12:03:33 +0200
Subject: [PATCH] Use `Gem::Package` like object instead of monkey patching.
1. This is similar to what RubyGems does and it is less magic [[1]].
2. It avoids deprecated code paths in RubyGems [[2]].
[1]: https://github.com/rubygems/rubygems/blob/92892bbc3adba86a90756c385433835f6761b8da/lib/rubygems/installer.rb#L151
[2]: https://github.com/rubygems/rubygems/blob/92892bbc3adba86a90756c385433835f6761b8da/lib/rubygems/installer.rb#L187
(cherry picked from commit e960ef6f18a25c637c54f00c75bb6c24f8ab55d0)
---
tool/rbinstall.rb | 47 +++++++++++++++++++++++++++--------------------
1 file changed, 27 insertions(+), 20 deletions(-)
diff --git a/tool/rbinstall.rb b/tool/rbinstall.rb
index 060390626f..28ae8c409a 100755
--- a/tool/rbinstall.rb
+++ b/tool/rbinstall.rb
@@ -710,28 +710,34 @@ def remove_prefix(prefix, string)
end
end
- class UnpackedInstaller < Gem::Installer
- module DirPackage
- def extract_files(destination_dir, pattern = "*")
- path = File.dirname(@gem.path)
- return if path == destination_dir
- File.chmod(0700, destination_dir)
- mode = pattern == "bin/*" ? $script_mode : $data_mode
- spec.files.each do |f|
- src = File.join(path, f)
- dest = File.join(without_destdir(destination_dir), f)
- makedirs(dest[/.*(?=\/)/m])
- install src, dest, :mode => mode
- end
- File.chmod($dir_mode, destination_dir)
+ class DirPackage
+ attr_reader :spec
+
+ attr_accessor :dir_mode
+ attr_accessor :prog_mode
+ attr_accessor :data_mode
+
+ def initialize(spec)
+ @spec = spec
+ @src_dir = File.dirname(@spec.loaded_from)
+ end
+
+ def extract_files(destination_dir, pattern = "*")
+ path = @src_dir
+ return if path == destination_dir
+ File.chmod(0700, destination_dir)
+ mode = pattern == "bin/*" ? $script_mode : $data_mode
+ spec.files.each do |f|
+ src = File.join(path, f)
+ dest = File.join(without_destdir(destination_dir), f)
+ makedirs(dest[/.*(?=\/)/m])
+ install src, dest, :mode => mode
end
+ File.chmod($dir_mode, destination_dir)
end
+ end
- def initialize(spec, *options)
- super(spec.loaded_from, *options)
- @package.extend(DirPackage).spec = spec
- end
-
+ class UnpackedInstaller < Gem::Installer
def write_cache_file
end
@@ -890,7 +896,8 @@ def install_default_gem(dir, srcdir)
if File.directory?(ext = "#{gem_ext_dir}/#{spec.full_name}")
spec.extensions[0] ||= "-"
end
- ins = RbInstall::UnpackedInstaller.new(spec, options)
+ package = RbInstall::DirPackage.new spec
+ ins = RbInstall::UnpackedInstaller.new(package, options)
puts "#{INDENT}#{spec.name} #{spec.version}"
ins.install
File.chmod($data_mode, File.join(install_dir, "specifications", "#{spec.full_name}.gemspec"))
--
2.35.1

View File

@ -6,7 +6,7 @@ let
stdenv = pkgs.stdenv;
rubyVersions = with pkgs; [
ruby_2_7
ruby_3_2
];
gemTests =

View File

@ -18024,7 +18024,6 @@ with pkgs;
})
mkRubyVersion
mkRuby
ruby_2_7
ruby_3_1
ruby_3_2
ruby_3_3;
@ -18032,7 +18031,6 @@ with pkgs;
ruby = ruby_3_1;
rubyPackages = rubyPackages_3_1;
rubyPackages_2_7 = recurseIntoAttrs ruby_2_7.gems;
rubyPackages_3_1 = recurseIntoAttrs ruby_3_1.gems;
rubyPackages_3_2 = recurseIntoAttrs ruby_3_2.gems;
rubyPackages_3_3 = recurseIntoAttrs ruby_3_3.gems;

View File

@ -768,11 +768,6 @@
"python3"
]
},
"ruby-2.7": {
"attrPath": [
"ruby_2_7"
]
},
"ruby-3.1": {
"attrPath": [
"ruby_3_1"