@@ -8,7 +8,29 @@ in
88
99rec {
1010
11− inherit (builtins) stringLength substring head tail isString replaceStrings;
11+ inherit (builtins)
12+ compareVersions
13+ elem
14+ elemAt
15+ filter
16+ fromJSON
17+ head
18+ isInt
19+ isList
20+ isString
21+ match
22+ parseDrvName
23+ readFile
24+ replaceStrings
25+ split
26+ storeDir
27+ stringLength
28+ substring
29+ tail
30+ toJSON
31+ typeOf
32+ unsafeDiscardStringContext
33+ ;
1234
1335 /* Concatenate a list of strings.
1436
@@ -120,7 +142,7 @@ rec {
120142 subDir:
121143 # List of base paths
122144 paths:
123− concatStringsSep ":" (map (path: path + "/" + subDir) (builtins.filter (x: x != null) paths));
145+ concatStringsSep ":" (map (path: path + "/" + subDir) (filter (x: x != null) paths));
124146
125147 /* Construct a Unix-style search path by appending the given
126148 `subDir` to the specified `output` of each of the packages. If no
@@ -313,7 +335,7 @@ rec {
313335 escapeNixString "hello\${}\n"
314336 => "\"hello\\\${}\\n\""
315337 */
316− escapeNixString = s: escape ["$"] (builtins.toJSON s);
338+ escapeNixString = s: escape ["$"] (toJSON s);
317339
318340 /* Turn a string into an exact regular expression
319341
@@ -337,7 +359,7 @@ rec {
337359 */
338360 escapeNixIdentifier = s:
339361 # Regex from https://github.com/NixOS/nix/blob/d048577909e383439c2549e849c5c2f2016c997e/src/libexpr/lexer.l#L91
340− if builtins.match "[a-zA-Z_][a-zA-Z0-9_'-]*" s != null
362+ if match "[a-zA-Z_][a-zA-Z0-9_'-]*" s != null
341363 then s else escapeNixString s;
342364
343365 # Obsolete - use replaceStrings instead.
@@ -466,7 +488,7 @@ rec {
466488 versionOlder "1.1" "1.1"
467489 => false
468490 */
469− versionOlder = v1: v2: builtins.compareVersions v2 v1 == 1;
491+ versionOlder = v1: v2: compareVersions v2 v1 == 1;
470492
471493 /* Return true if string v1 denotes a version equal to or newer than v2.
472494
@@ -492,7 +514,7 @@ rec {
492514 */
493515 getName = x:
494516 let
495− parse = drv: (builtins.parseDrvName drv).name;
517+ parse = drv: (parseDrvName drv).name;
496518 in if isString x
497519 then parse x
498520 else x.pname or (parse x.name);
@@ -509,7 +531,7 @@ rec {
509531 */
510532 getVersion = x:
511533 let
512− parse = drv: (builtins.parseDrvName drv).version;
534+ parse = drv: (parseDrvName drv).version;
513535 in if isString x
514536 then parse x
515537 else x.version or (parse x.name);
@@ -527,7 +549,7 @@ rec {
527549 let
528550 components = splitString "/" url;
529551 filename = lib.last components;
530− name = builtins.head (splitString sep filename);
552+ name = head (splitString sep filename);
531553 in assert name != filename; name;
532554
533555 /* Create an --{enable,disable}-<feat> string that can be passed to
@@ -617,14 +639,14 @@ rec {
617639 */
618640 floatToString = float: let
619641 result = toString float;
620− precise = float == builtins.fromJSON result;
642+ precise = float == fromJSON result;
621643 in if precise then result
622644 else lib.warn "Imprecise conversion from float to string ${result}" result;
623645
624646 /* Check whether a value can be coerced to a string */
625647 isCoercibleToString = x:
626− builtins.elem (builtins.typeOf x) [ "path" "string" "null" "int" "float" "bool" ] ||
627− (builtins.isList x && lib.all isCoercibleToString x) ||
648+ elem (typeOf x) [ "path" "string" "null" "int" "float" "bool" ] ||
649+ (isList x && lib.all isCoercibleToString x) ||
628650 x ? outPath ||
629651 x ? __toString;
630652
@@ -643,8 +665,8 @@ rec {
643665 isStorePath = x:
644666 if isCoercibleToString x then
645667 let str = toString x; in
646− builtins.substring 0 1 str == "/"
647− && dirOf str == builtins.storeDir
668+ substring 0 1 str == "/"
669+ && dirOf str == storeDir
648670 else
649671 false;
650672
@@ -662,8 +684,8 @@ rec {
662684 */
663685 # Obviously, it is a bit hacky to use fromJSON this way.
664686 toInt = str:
665− let may_be_int = builtins.fromJSON str; in
666− if builtins.isInt may_be_int
687+ let may_be_int = fromJSON str; in
688+ if isInt may_be_int
667689 then may_be_int
668690 else throw "Could not convert ${str} to int.";
669691
@@ -685,10 +707,10 @@ rec {
685707 readPathsFromFile = lib.warn "lib.readPathsFromFile is deprecated, use a list instead"
686708 (rootPath: file:
687709 let
688− lines = lib.splitString "\n" (builtins.readFile file);
710+ lines = lib.splitString "\n" (readFile file);
689711 removeComments = lib.filter (line: line != "" && !(lib.hasPrefix "#" line));
690712 relativePaths = removeComments lines;
691− absolutePaths = builtins.map (path: rootPath + "/${path}") relativePaths;
713+ absolutePaths = map (path: rootPath + "/${path}") relativePaths;
692714 in
693715 absolutePaths);
694716
@@ -702,7 +724,7 @@ rec {
702724 fileContents ./version
703725 => "1.0"
704726 */
705− fileContents = file: removeSuffix "\n" (builtins.readFile file);
727+ fileContents = file: removeSuffix "\n" (readFile file);
706728
707729
708730 /* Creates a valid derivation name from a potentially invalid one.
@@ -720,13 +742,13 @@ rec {
720742 sanitizeDerivationName = string: lib.pipe string [
721743 # Get rid of string context. This is safe under the assumption that the
722744 # resulting string is only used as a derivation name
723− builtins.unsafeDiscardStringContext
745+ unsafeDiscardStringContext
724746 # Strip all leading "."
725− (x: builtins.elemAt (builtins.match "\\.*(.*)" x) 0)
747+ (x: elemAt (match "\\.*(.*)" x) 0)
726748 # Split out all invalid characters
727749 # https://github.com/NixOS/nix/blob/2.3.2/src/libstore/store-api.cc#L85-L112
728750 # https://github.com/NixOS/nix/blob/2242be83c61788b9c0736a92bb0b5c7bbfc40803/nix-rust/src/store/path.rs#L100-L125
729− (builtins.split "[^[:alnum:]+._?=-]+")
751+ (split "[^[:alnum:]+._?=-]+")
730752 # Replace invalid character ranges with a "-"
731753 (concatMapStrings (s: if lib.isList s then "-" else s))
732754 # Limit to 211 characters (minus 4 chars for ".drv")