1/* Version string functions. */
2{ lib }:
3
4let
5
6 splitVersion = builtins.splitVersion or (lib.splitString ".");
7
8in
9
10rec {
11
12 /* Get the major version string from a string.
13
14 Example:
15 major "1.2.3"
16 => "1"
17 */
18 major = v: builtins.elemAt (splitVersion v) 0;
19
20 /* Get the minor version string from a string.
21
22 Example:
23 minor "1.2.3"
24 => "2"
25 */
26 minor = v: builtins.elemAt (splitVersion v) 1;
27
28 /* Get the patch version string from a string.
29
30 Example:
31 patch "1.2.3"
32 => "3"
33 */
34 patch = v: builtins.elemAt (splitVersion v) 2;
35
36 /* Get string of the first two parts (major and minor)
37 of a version string.
38
39 Example:
40 majorMinor "1.2.3"
41 => "1.2"
42 */
43 majorMinor = v:
44 builtins.concatStringsSep "."
45 (lib.take 2 (splitVersion v));
46
47}