Skip to content

lib.versions: version string functions

Version string functions.

lib.versions.splitVersion

Break a version string into its component parts.

Example

# `lib.versions.splitVersion` usage example
splitVersion "1.2.3"
=> ["1" "2" "3"]

Located at lib/versions.nix:12 in <nixpkgs>.

lib.versions.major

Get the major version string from a string.

v

: Function argument

Example

lib.versions.major usage example

major "1.2.3"
=> "1"

Located at lib/versions.nix:20 in <nixpkgs>.

lib.versions.minor

Get the minor version string from a string.

v

: Function argument

Example

lib.versions.minor usage example

minor "1.2.3"
=> "2"

Located at lib/versions.nix:28 in <nixpkgs>.

lib.versions.patch

Get the patch version string from a string.

v

: Function argument

Example

lib.versions.patch usage example

patch "1.2.3"
=> "3"

Located at lib/versions.nix:36 in <nixpkgs>.

lib.versions.majorMinor

Get string of the first two parts (major and minor) of a version string.

v

: Function argument

Example

lib.versions.majorMinor usage example

majorMinor "1.2.3"
=> "1.2"

Located at lib/versions.nix:45 in <nixpkgs>.

lib.versions.pad

Pad a version string with zeros to match the given number of components.

n

: Function argument

version

: Function argument

Example

lib.versions.pad usage example

pad 3 "1.2"
=> "1.2.0"
pad 3 "1.3-rc1"
=> "1.3.0-rc1"
pad 3 "1.2.3.4"
=> "1.2.3"

Located at lib/versions.nix:59 in <nixpkgs>.