about summary refs log tree commit diff
path: root/lib/strings.nix
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2014-05-09 15:50:40 +0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2014-05-09 15:53:44 +0200
commitea36f3b86892263d172fa3d0d0d4ae00d82a0edc (patch)
tree91862989d1274c3257ea267814eb2bb071a01580 /lib/strings.nix
parent0d50061b4f9a23d5d2d61404a4d38122603f2b63 (diff)
fetchFromGitHub: Use .tar.gz instead of .zip
Also clean up the name attribute of fetchzip derivations a bit.
Diffstat (limited to 'lib/strings.nix')
-rw-r--r--lib/strings.nix10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/strings.nix b/lib/strings.nix
index cd748f02cc635..a903aa9fbc49e 100644
--- a/lib/strings.nix
+++ b/lib/strings.nix
@@ -160,6 +160,16 @@ rec {
       else
         s;
 
+  removeSuffix = suf: s:
+    let
+      sufLen = stringLength suf;
+      sLen = stringLength s;
+    in
+      if sufLen <= sLen && suf == substring (sLen - sufLen) sufLen s then
+        substring 0 (sLen - sufLen) s
+      else
+        s;
+
   # Return true iff string v1 denotes a version older than v2.
   versionOlder = v1: v2: builtins.compareVersions v2 v1 == 1;