summary refs log tree commit diff
path: root/pkgs/lib/strings.nix
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2012-10-05 13:45:27 -0400
committerEelco Dolstra <eelco.dolstra@logicblox.com>2012-10-05 13:48:57 -0400
commite0be32f6760e26aab599a09ee2b4d71b4497f7e8 (patch)
tree58d78ddf5ec2b2ee3cc941a9666fb7041fba0771 /pkgs/lib/strings.nix
parent172abb4b26e0453300fa873c5256f4b171258486 (diff)
downloadnixpkgs-e0be32f6760e26aab599a09ee2b4d71b4497f7e8.tar
nixpkgs-e0be32f6760e26aab599a09ee2b4d71b4497f7e8.tar.gz
nixpkgs-e0be32f6760e26aab599a09ee2b4d71b4497f7e8.tar.bz2
nixpkgs-e0be32f6760e26aab599a09ee2b4d71b4497f7e8.tar.lz
nixpkgs-e0be32f6760e26aab599a09ee2b4d71b4497f7e8.tar.xz
nixpkgs-e0be32f6760e26aab599a09ee2b4d71b4497f7e8.tar.zst
nixpkgs-e0be32f6760e26aab599a09ee2b4d71b4497f7e8.zip
Add a function ‘getVersion’ to get the version of a derivation
Diffstat (limited to 'pkgs/lib/strings.nix')
-rw-r--r--pkgs/lib/strings.nix6
1 files changed, 6 insertions, 0 deletions
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