Hi all, and @manveru @marsam in particular since you’re listed as maintainers of nixpkgs/pkgs/development/interpreters/ruby/default.nix
.
There are specific revisions of ruby available in nixpkgs like ruby_2_7, ruby_3_0 and ruby_3_1. If I want an older one I can refer to Nix Package Versions to see what’s been provided in the past.
BUT, some point revisions were never part of the nixpkgs history, unfortunately. For example, ruby_2_6 seems to have gone as far as 2.6.8 but skipped 2.6.9.
So I tried to override the derivation to make 2.6.9. But this seems to fail because it needs a bundle update or something.
Building specific nodejs versions we have the nixpkgs function buildNodeJs = pkgs.callPackage <nixpkgs/pkgs/development/web/nodejs/nodejs.nix> {};
. There doesn’t appear to be such a function for ruby.
So what suggestions do you have for how to build a derivation for ruby versions that weren’t released in nixpkgs? Obviously if ruby had binaries I’d use that, but a project I need to use wants 2.6.9 and nix isn’t giving that to me atm.
let
rubyVersion = import <nixpkgs/pkgs/development/interpreters/ruby/ruby-version.nix> { inherit lib; };
# https://lazamar.co.uk/nix-versions/?package=ruby&version=2.6.8&fullName=ruby-2.6.8&keyName=ruby_2_6&revision=2cdd608fab0af07647da29634627a42852a8c97f&channel=nixpkgs-unstable#instructions
pkgs_ruby268 = import (builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/2cdd608fab0af07647da29634627a42852a8c97f.tar.gz";
sha256 = "1szv364xr25yqlljrlclv8z2lm2n1qva56ad9vd02zcmn2pimdih";
}) {};
ruby_2_6_8 = pkgs_ruby268.ruby_2_6;
ruby_2_6_9 = {
version = rubyVersion "2" "6" "9" "";
package = ruby_2_6_8.overrideAttrs(oldAttrs: rec {
version = ruby_2_6_9.version;
src = builtins.fetchurl {
url = "https://cache.ruby-lang.org/pub/ruby/2.6/ruby-2.6.9.tar.xz";
sha256 = "6a041d82ae6e0f02ccb1465e620d94a7196489d8a13d6018a160da42ebc1eece";
};
passthru = oldAttrs.passthru // {
version = ruby_2_6_9.version;
};
});
rubies = with pkgs; [
ruby_2_6_8
ruby_2_6_9.package
ruby_2_7
ruby_3_0
ruby_3_1
in
{
# start pseudo code
install each ruby into home.file="~/.rubies/ruby-<version>"
# end pseudo code
}
Output log:
...
installing default gems from lib: /nix/store/3c6kbcq87ih12bpkzr8phhrmkm3cipjx-ruby-2.6.9/lib/ruby/gems/2.6.0 (build_info, cache, doc, extensions, gems, plugins, specifications)
bundler 1.17.2
cmath 1.0.0
csv 3.0.9
e2mmap 0.1.0
fileutils 1.1.0
forwardable 1.2.0
ipaddr 1.2.2
irb 1.0.0
logger 1.3.0
matrix 0.1.0
mutex_m 0.1.0
ostruct 0.1.0
prime 0.1.0
rdoc 6.1.2.1
rexml 3.1.9.1
rss 0.2.7
scanf 1.0.0
shell 0.7
sync 0.5.0
thwait 0.1.0
tracer 0.1.0
webrick 1.4.4
installing default gems from ext: /nix/store/3c6kbcq87ih12bpkzr8phhrmkm3cipjx-ruby-2.6.9/lib/ruby/gems/2.6.0 (build_info, cache, doc, extensions, gems, plugins, specifications)
bigdecimal 1.4.1
date 2.0.2
dbm 1.0.0
etc 1.0.1
fcntl 1.0.0
fiddle 1.0.0
gdbm 2.0.0
io-console 0.4.7
json 2.1.0
openssl 2.1.2
psych 3.1.0
sdbm 1.0.0
stringio 0.0.2
strscan 1.0.0
zlib 1.0.0
installing bundled gems: /nix/store/3c6kbcq87ih12bpkzr8phhrmkm3cipjx-ruby-2.6.9/lib/ruby/gems/2.6.0 (build_info, cache, doc, extensions, gems, plugins, specifications)
/private/tmp/nix-build-ruby-2.6.9.drv-0/ruby-2.6.9/lib/rubygems/installer.rb:179:in `initialize': undefined method `dir_mode=' for #<String:0x00007fc12c87df08> (NoMethodError)
from ./tool/rbinstall.rb:725:in `initialize'
from ./tool/rbinstall.rb:878:in `new'
from ./tool/rbinstall.rb:878:in `block (2 levels) in <main>'
from /private/tmp/nix-build-ruby-2.6.9.drv-0/ruby-2.6.9/lib/rubygems/specification.rb:768:in `block (2 levels) in each_gemspec'
from /private/tmp/nix-build-ruby-2.6.9.drv-0/ruby-2.6.9/lib/rubygems/specification.rb:767:in `each'
from /private/tmp/nix-build-ruby-2.6.9.drv-0/ruby-2.6.9/lib/rubygems/specification.rb:767:in `block in each_gemspec'
from /private/tmp/nix-build-ruby-2.6.9.drv-0/ruby-2.6.9/lib/rubygems/specification.rb:766:in `each'
from /private/tmp/nix-build-ruby-2.6.9.drv-0/ruby-2.6.9/lib/rubygems/specification.rb:766:in `each_gemspec'
from ./tool/rbinstall.rb:870:in `block in <main>'
from ./tool/rbinstall.rb:937:in `block in <main>'
from ./tool/rbinstall.rb:934:in `each'
from ./tool/rbinstall.rb:934:in `<main>'
make: *** [uncommon.mk:364: do-install-all] Error 1
error: builder for '/nix/store/1jaaicdvrhnkwbmympqm2wzfmi8lyssb-ruby-2.6.9.drv' failed with exit code 2;
last 10 log lines:
> from /private/tmp/nix-build-ruby-2.6.9.drv-0/ruby-2.6.9/lib/rubygems/specification.rb:768:in `block (2 levels) in each_gemspec'
> from /private/tmp/nix-build-ruby-2.6.9.drv-0/ruby-2.6.9/lib/rubygems/specification.rb:767:in `each'
> from /private/tmp/nix-build-ruby-2.6.9.drv-0/ruby-2.6.9/lib/rubygems/specification.rb:767:in `block in each_gemspec'
> from /private/tmp/nix-build-ruby-2.6.9.drv-0/ruby-2.6.9/lib/rubygems/specification.rb:766:in `each'
> from /private/tmp/nix-build-ruby-2.6.9.drv-0/ruby-2.6.9/lib/rubygems/specification.rb:766:in `each_gemspec'
> from ./tool/rbinstall.rb:870:in `block in <main>'
> from ./tool/rbinstall.rb:937:in `block in <main>'
> from ./tool/rbinstall.rb:934:in `each'
> from ./tool/rbinstall.rb:934:in `<main>'
> make: *** [uncommon.mk:364: do-install-all] Error 1
For full logs, run 'nix log /nix/store/1jaaicdvrhnkwbmympqm2wzfmi8lyssb-ruby-2.6.9.drv'.
error: 1 dependencies of derivation '/nix/store/wn57jk9rhm0dk20yx6z7kgv3z5yyj944-home-manager-files.drv' failed to build
error: 1 dependencies of derivation '/nix/store/z8fsxr7wmkmx6hb0bhjmbd2klf95las3-home-manager-generation.drv' failed to build