From e0be32f6760e26aab599a09ee2b4d71b4497f7e8 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 5 Oct 2012 13:45:27 -0400 Subject: [PATCH] =?UTF-8?q?Add=20a=20function=20=E2=80=98getVersion?= =?UTF-8?q?=E2=80=99=20to=20get=20the=20version=20of=20a=20derivation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkgs/lib/strings.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkgs/lib/strings.nix b/pkgs/lib/strings.nix index 4bd7a5bebde..19d1738182f 100644 --- a/pkgs/lib/strings.nix +++ b/pkgs/lib/strings.nix @@ -155,6 +155,12 @@ rec { # Return true iff string v1 denotes a version older than v2. versionOlder = v1: v2: builtins.compareVersions v2 v1 == 1; + + # Get the version of the specified derivation, as specified in its + # ‘name’ attribute. + getVersion = drv: (builtins.parseDrvName drv.name).version; + + # Extract name with version from URL. Ask for separator which is # supposed to start extension nameFromURL = url: sep: let