1 # Contains the ruby version heuristics
5 # The returned set should be immutable
6 rubyVersion = major: minor: tiny: tail:
8 inherit major minor tiny tail;
10 # Contains the patch number "223" if tail is "p223" or null
13 p = lib.removePrefix "p" tail;
17 ["0" "1" "2" "3" "4" "5" "6" "7" "8" "9"]
18 ["" "" "" "" "" "" "" "" "" "" ]
21 if lib.hasPrefix "p" tail && isPosInt p then p
25 majMin = "${major}.${minor}";
26 majMinTiny = "${major}.${minor}.${tiny}";
28 # Ruby separates lib and gem folders by ABI version which isn't very
31 if lib.versionAtLeast majMinTiny "2.1.0" then
33 else if lib.versionAtLeast majMinTiny "2.0.0" then
35 else if lib.versionAtLeast majMinTiny "1.9.1" then
38 throw "version ${majMinTiny} is not supported";
40 # How ruby releases are tagged on github.com/ruby/ruby
43 base = "v${major}_${minor}_${tiny}";
45 if patchLevel != null then
46 "${base}_${patchLevel}"
53 # Implements the builtins.toString interface.
56 if self.patchLevel != null then
57 "-p${self.patchLevel}"
59 lib.optionalString (self.tail != "") "-${self.tail}"