1{ _cuda, lib }:
2let
3 cudaLib = _cuda.lib;
4in
5{
6 /**
7 Extracts the major, minor, and patch version from a string.
8
9 # Type
10
11 ```
12 majorMinorPatch :: (version :: String) -> String
13 ```
14
15 # Inputs
16
17 `version`
18
19 : The version string
20
21 # Examples
22
23 :::{.example}
24 ## `_cuda.lib.majorMinorPatch` usage examples
25
26 ```nix
27 majorMinorPatch "11.0.3.4"
28 => "11.0.3"
29 ```
30 :::
31 */
32 majorMinorPatch = cudaLib.trimComponents 3;
33
34 /**
35 Get a version string with no more than than the specified number of components.
36
37 # Type
38
39 ```
40 trimComponents :: (numComponents :: Integer) -> (version :: String) -> String
41 ```
42
43 # Inputs
44
45 `numComponents`
46 : A positive integer corresponding to the maximum number of components to keep
47
48 `version`
49 : A version string
50
51 # Examples
52
53 :::{.example}
54 ## `_cuda.lib.trimComponents` usage examples
55
56 ```nix
57 trimComponents 1 "1.2.3.4"
58 => "1"
59 ```
60
61 ```nix
62 trimComponents 3 "1.2.3.4"
63 => "1.2.3"
64 ```
65
66 ```nix
67 trimComponents 9 "1.2.3.4"
68 => "1.2.3.4"
69 ```
70 :::
71 */
72 trimComponents =
73 n: v:
74 lib.pipe v [
75 lib.splitVersion
76 (lib.take n)
77 (lib.concatStringsSep ".")
78 ];
79}