diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/debug.nix | 28 | ||||
-rw-r--r-- | lib/licenses.nix | 6 | ||||
-rw-r--r-- | lib/lists.nix | 2 | ||||
-rw-r--r-- | lib/sources.nix | 6 | ||||
-rw-r--r-- | lib/strings.nix | 12 | ||||
-rw-r--r-- | lib/trivial.nix | 2 |
6 files changed, 25 insertions, 31 deletions
diff --git a/lib/debug.nix b/lib/debug.nix index 2d10d981114c..e2e895ab6202 100644 --- a/lib/debug.nix +++ b/lib/debug.nix @@ -19,6 +19,10 @@ rec { traceXMLVal = x: trace (builtins.toXML x) x; traceXMLValMarked = str: x: trace (str + builtins.toXML x) x; + # strict trace functions (traced structure is fully evaluated and printed) + traceSeq = x: y: trace (builtins.deepSeq x x) y; + traceValSeq = v: traceVal (builtins.deepSeq v v); + # this can help debug your code as well - designed to not produce thousands of lines traceShowVal = x : trace (showVal x) x; traceShowValMarked = str: x: trace (str + showVal x) x; @@ -69,27 +73,9 @@ rec { # usage: { testX = allTrue [ true ]; } testAllTrue = expr : { inherit expr; expected = map (x: true) expr; }; - # evaluate everything once so that errors will occur earlier - # hacky: traverse attrs by adding a dummy - # ignores functions (should this behavior change?) See strictf - # - # Note: This should be a primop! Something like seq of haskell would be nice to - # have as well. It's used fore debugging only anyway - strict = x : - let - traverse = x : - if isString x then true - else if isAttrs x then - if x ? outPath then true - else all id (mapAttrsFlatten (n: traverse) x) - else if isList x then - all id (map traverse x) - else if isBool x then true - else if isFunction x then true - else if isInt x then true - else if x == null then true - else true; # a (store) path? - in if traverse x then x else throw "else never reached"; + strict = v: + trace "Warning: strict is deprecated and will be removed in the next release" + (builtins.seq v v); # example: (traceCallXml "myfun" id 3) will output something like # calling myfun arg 1: 3 result: 3 diff --git a/lib/licenses.nix b/lib/licenses.nix index 4071fcfd70d2..c91b0c21a061 100644 --- a/lib/licenses.nix +++ b/lib/licenses.nix @@ -200,6 +200,12 @@ lib.mapAttrs (n: v: v // { shortName = n; }) rec { url = https://geant4.web.cern.ch/geant4/license/LICENSE.html; }; + geogebra = { + fullName = "GeoGebra Non-Commercial License Agreement"; + url = https://www.geogebra.org/license; + free = false; + }; + gpl1 = spdx { spdxId = "GPL-1.0"; fullName = "GNU General Public License v1.0 only"; diff --git a/lib/lists.nix b/lib/lists.nix index 6712e5cc93f8..78ffa753ac33 100644 --- a/lib/lists.nix +++ b/lib/lists.nix @@ -89,7 +89,7 @@ rec { */ flatten = x: if isList x - then foldl' (x: y: x ++ (flatten y)) [] x + then concatMap (y: flatten y) x else [x]; /* Remove elements equal to 'e' from a list. Useful for buildInputs. diff --git a/lib/sources.nix b/lib/sources.nix index c1ec02b9c26c..156afaae5c98 100644 --- a/lib/sources.nix +++ b/lib/sources.nix @@ -20,7 +20,9 @@ rec { lib.hasSuffix "~" baseName || # Filter out generates files. lib.hasSuffix ".o" baseName || - lib.hasSuffix ".so" baseName + lib.hasSuffix ".so" baseName || + # Filter out nix-build result symlinks + (type == "symlink" && lib.hasPrefix "result" baseName) ); in src: builtins.filterSource filter src; @@ -56,7 +58,7 @@ rec { else if lib.pathExists packedRefsName then let fileContent = readFile packedRefsName; - matchRef = match ".*\n([^\n ]*) " + file + "\n.*" fileContent; + matchRef = match (".*\n([^\n ]*) " + file + "\n.*") fileContent; in if isNull matchRef then throw ("Could not find " + file + " in " + packedRefsName) else lib.head matchRef diff --git a/lib/strings.nix b/lib/strings.nix index daf845839343..89169411a021 100644 --- a/lib/strings.nix +++ b/lib/strings.nix @@ -156,12 +156,12 @@ rec { hasSuffix "foo" "barfoo" => true */ - hasSuffix = suff: str: + hasSuffix = suffix: content: let - lenStr = stringLength str; - lenSuff = stringLength suff; - in lenStr >= lenSuff && - substring (lenStr - lenSuff) lenStr str == suff; + lenContent = stringLength content; + lenSuffix = stringLength suffix; + in lenContent >= lenSuffix && + substring (lenContent - lenSuffix) lenContent content == suffix; /* Convert a string to a list of characters (i.e. singleton strings). This allows you to, e.g., map a function over each character. However, @@ -248,7 +248,7 @@ rec { /* Converts an ASCII string to upper-case. Example: - toLower "home" + toUpper "home" => "HOME" */ toUpper = replaceChars lowerChars upperChars; diff --git a/lib/trivial.nix b/lib/trivial.nix index f85c74ab88e3..21642ca0bdc1 100644 --- a/lib/trivial.nix +++ b/lib/trivial.nix @@ -71,7 +71,7 @@ rec { + (if pathExists suffixFile then fileContents suffixFile else "pre-git"); # Whether we're being called by nix-shell. - inNixShell = builtins.getEnv "IN_NIX_SHELL" == "1"; + inNixShell = builtins.getEnv "IN_NIX_SHELL" != ""; # Return minimum/maximum of two numbers. min = x: y: if x < y then x else y; |