But when I run nix-shell default.nix --show-trace I get the output:
error: while evaluating the attribute 'buildInputs' of the derivation 'mortgages' at /path/to/project/default.nix:9:3:
while evaluating 'getOutput' at /nix/store/vifxvc1qnb4g672zp3nf9bm6jr2p631x-nixpkgs-19.09pre187222.002b853782e/nixpkgs/lib/attrsets.nix:464:23, called from undefined position:
while evaluating anonymous function at /nix/store/vifxvc1qnb4g672zp3nf9bm6jr2p631x-nixpkgs-19.09pre187222.002b853782e/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:142:17, called from undefined position:
attribute 'ruby_2_2_4' missing, at/path/to/project/default.nix:5:10
So my question is: what am I doing wrong? Do I have to target an older nixpkgs version in order to get my desired results?
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:
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.
This looks good, even though I fear I’ll have to go through the manual process, because I really don’t want to change anything in this project. This has to be the reference implementation hence I’d rather replicate the dependencies as close as possible.
I don’t use it anymore, but I can imagine that it still works if that version of Ruby is able to compile against your version of nixpkgs. The list of ruby versions is at least still being kept up to date by running GitHub - bobvanderlinden/nixpkgs-ruby-updater daily.