2015-06-18 19:21:54 +00:00
|
|
|
{ lib, pkgs, ... }:
|
2015-03-05 12:01:05 +00:00
|
|
|
|
|
|
|
with builtins;
|
|
|
|
|
|
|
|
let
|
2015-06-14 17:15:56 +00:00
|
|
|
inherit (lib) mapAttrs stringAsChars;
|
2015-03-05 12:01:05 +00:00
|
|
|
in
|
|
|
|
|
2015-06-14 17:15:56 +00:00
|
|
|
rec {
|
|
|
|
git = import ./git.nix {
|
|
|
|
lib = lib // {
|
|
|
|
inherit addNames;
|
|
|
|
};
|
2015-06-18 19:21:54 +00:00
|
|
|
inherit pkgs;
|
2015-06-14 17:15:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
addName = name: set:
|
|
|
|
set // { inherit name; };
|
|
|
|
|
|
|
|
addNames = mapAttrs addName;
|
2015-03-05 12:01:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
# "7.4.335" -> "74"
|
2015-06-14 16:48:53 +00:00
|
|
|
majmin = with lib; x : concatStrings (take 2 (splitString "." x));
|
2015-03-05 12:01:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
concat = xs :
|
|
|
|
if xs == []
|
|
|
|
then ""
|
|
|
|
else head xs + concat (tail xs)
|
|
|
|
;
|
|
|
|
|
|
|
|
flip = f : x : y : f y x;
|
|
|
|
|
|
|
|
# isSuffixOf :: String -> String -> Bool
|
|
|
|
isSuffixOf =
|
|
|
|
s : xs :
|
|
|
|
let
|
|
|
|
sn = stringLength s;
|
|
|
|
xsn = stringLength xs;
|
|
|
|
in
|
|
|
|
xsn >= sn && substring (xsn - sn) sn xs == s ;
|
|
|
|
|
|
|
|
removeSuffix =
|
|
|
|
s : xs : substring 0 (stringLength xs - stringLength s) xs;
|
|
|
|
|
|
|
|
# setMap :: (String -> a -> b) -> Set String a -> [b]
|
|
|
|
#setMap = f: xs: map (k : f k (getAttr k xs)) (attrNames xs);
|
|
|
|
|
|
|
|
# setToList :: Set k a -> [a]
|
|
|
|
#setToList = setMap (_: v: v);
|
|
|
|
|
|
|
|
shell-escape =
|
2015-03-17 06:47:09 +00:00
|
|
|
let
|
|
|
|
isSafeChar = c: match "[-./0-9_a-zA-Z]" c != null;
|
|
|
|
in
|
|
|
|
stringAsChars (c:
|
|
|
|
if isSafeChar c then c
|
|
|
|
else if c == "\n" then "'\n'"
|
|
|
|
else "\\${c}");
|
|
|
|
|
2015-03-05 12:01:05 +00:00
|
|
|
}
|