Legacy ruby version

That’s correct, you’re using the default “nixpkgs” channel on your system by using the <nixpkgs> import. You can get the older ruby by using something like this:

import (builtins.fetchTarball {
  name = "nixos-unstable-2018-09-12";
  url = https://github.com/nixos/nixpkgs/archive/ca2ba44cab47767c8127d1c8633e2b581644eb8f.tar.gz;
  # Hash obtained using `nix-prefetch-url --unpack <url>`
  sha256 = "1jg7g6cfpw8qvma0y19kwyp549k1qyf11a5sg6hvn6awvmkny47v";
}) {}

Looking at https://hydra.nixos.org/search?query=ruby_2_2 we never had a 2.2.4 version in nixpkgs, so you’ll have to use either 2.2.3 or 2.2.5.

There are other ways, like building it yourself by modifying the version/hash in nixpkgs, but I think 2.2.5 should be fully compatible with 2.2.4 so I’d instead recommend that first.

Getting the nixpkgs revision for the version you want is also easy by looking at Hydra (not sure which OS you’re using so I’ll just assume a x86_64-linux:
https://hydra.nixos.org/job/nixos/release-17.03/nixpkgs.ruby_2_2_5.x86_64-linux#tabs-status
Click on the last successful build and from there go to the “Inputs” tab, which shows you which version of nixpkgs it was built with.

It is also easy to mix two versions of nixpkgs for different packages, so you only have to take Ruby from this ancient checkout and the rest of the packages can be more recent by simply assigning it to a different variable than pkgs.

Hope this helps.

2 Likes