1 # Contains the ruby version heuristics
5 # The returned set should be immutable
6 rubyVersion = major: minor: tiny: tail: rec {
14 # Contains the patch number "223" if tail is "p223" or null
17 p = lib.removePrefix "p" tail;
20 0 == lib.stringLength (
49 if lib.hasPrefix "p" tail && isPosInt p then p else null;
52 majMin = "${major}.${minor}";
53 majMinTiny = "${major}.${minor}.${tiny}";
55 # Ruby separates lib and gem folders by ABI version which isn't very
58 if lib.versionAtLeast majMinTiny "2.1.0" then
60 else if lib.versionAtLeast majMinTiny "2.0.0" then
62 else if lib.versionAtLeast majMinTiny "1.9.1" then
65 throw "version ${majMinTiny} is not supported";
67 # How ruby releases are tagged on github.com/ruby/ruby
70 base = "v${major}_${minor}_${tiny}";
72 if patchLevel != null then
73 "${base}_${patchLevel}"
74 else if tail != "" then
79 # Implements the builtins.toString interface.
84 if self.patchLevel != null then
85 "-p${self.patchLevel}"
87 lib.optionalString (self.tail != "") "-${self.tail}"