Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s
80 lines
1.2 KiB
Nix
80 lines
1.2 KiB
Nix
{ _cuda, lib }:
|
|
let
|
|
cudaLib = _cuda.lib;
|
|
in
|
|
{
|
|
/**
|
|
Extracts the major, minor, and patch version from a string.
|
|
|
|
# Type
|
|
|
|
```
|
|
majorMinorPatch :: (version :: String) -> String
|
|
```
|
|
|
|
# Inputs
|
|
|
|
`version`
|
|
|
|
: The version string
|
|
|
|
# Examples
|
|
|
|
:::{.example}
|
|
## `_cuda.lib.majorMinorPatch` usage examples
|
|
|
|
```nix
|
|
majorMinorPatch "11.0.3.4"
|
|
=> "11.0.3"
|
|
```
|
|
:::
|
|
*/
|
|
majorMinorPatch = cudaLib.trimComponents 3;
|
|
|
|
/**
|
|
Get a version string with no more than than the specified number of components.
|
|
|
|
# Type
|
|
|
|
```
|
|
trimComponents :: (numComponents :: Integer) -> (version :: String) -> String
|
|
```
|
|
|
|
# Inputs
|
|
|
|
`numComponents`
|
|
: A positive integer corresponding to the maximum number of components to keep
|
|
|
|
`version`
|
|
: A version string
|
|
|
|
# Examples
|
|
|
|
:::{.example}
|
|
## `_cuda.lib.trimComponents` usage examples
|
|
|
|
```nix
|
|
trimComponents 1 "1.2.3.4"
|
|
=> "1"
|
|
```
|
|
|
|
```nix
|
|
trimComponents 3 "1.2.3.4"
|
|
=> "1.2.3"
|
|
```
|
|
|
|
```nix
|
|
trimComponents 9 "1.2.3.4"
|
|
=> "1.2.3.4"
|
|
```
|
|
:::
|
|
*/
|
|
trimComponents =
|
|
n: v:
|
|
lib.pipe v [
|
|
lib.splitVersion
|
|
(lib.take n)
|
|
(lib.concatStringsSep ".")
|
|
];
|
|
}
|