lib.getVersion: extend the function to cope with strings as well as derivations
This commit is contained in:
parent
9af5091992
commit
7ca8e13918
|
@ -189,9 +189,13 @@ rec {
|
||||||
versionAtLeast = v1: v2: !versionOlder v1 v2;
|
versionAtLeast = v1: v2: !versionOlder v1 v2;
|
||||||
|
|
||||||
|
|
||||||
# Get the version of the specified derivation, as specified in its
|
# This function takes an argument that's either a derivation or a
|
||||||
# ‘name’ attribute.
|
# derivation's "name" attribute and extracts the version part from that
|
||||||
getVersion = drv: (builtins.parseDrvName drv.name).version;
|
# argument. For example:
|
||||||
|
#
|
||||||
|
# lib.getVersion "youtube-dl-2016.01.01" ==> "2016.01.01"
|
||||||
|
# lib.getVersion pkgs.youtube-dl ==> "2016.01.01"
|
||||||
|
getVersion = x: (builtins.parseDrvName (x.name or x)).version;
|
||||||
|
|
||||||
|
|
||||||
# Extract name with version from URL. Ask for separator which is
|
# Extract name with version from URL. Ask for separator which is
|
||||||
|
|
Loading…
Reference in New Issue