diff --git a/lib/asserts.nix b/lib/asserts.nix index 41908d00a8126..c93254084b83f 100644 --- a/lib/asserts.nix +++ b/lib/asserts.nix @@ -47,7 +47,7 @@ rec { ::: */ # TODO(Profpatsch): add tests that check stderr - assertMsg = pred: msg: pred || builtins.throw msg; + assertMsg = pred: msg: pred || throw msg; /** Specialized `assertMsg` for checking if `val` is one of the elements diff --git a/lib/attrsets.nix b/lib/attrsets.nix index b13a3f6ef6371..de7859921c8c4 100644 --- a/lib/attrsets.nix +++ b/lib/attrsets.nix @@ -2149,7 +2149,7 @@ rec { chooseDevOutputs :: [Derivation] -> [Derivation] ``` */ - chooseDevOutputs = builtins.map getDev; + chooseDevOutputs = map getDev; /** Make various Nix tools consider the contents of the resulting @@ -2230,7 +2230,7 @@ rec { intersection = builtins.intersectAttrs x y; collisions = lib.concatStringsSep " " (builtins.attrNames intersection); mask = builtins.mapAttrs ( - name: value: builtins.throw "unionOfDisjoint: collision on ${name}; complete list: ${collisions}" + name: value: throw "unionOfDisjoint: collision on ${name}; complete list: ${collisions}" ) intersection; in (x // y) // mask; diff --git a/lib/deprecated/misc.nix b/lib/deprecated/misc.nix index 22015c9b20aa6..b5511e949a416 100644 --- a/lib/deprecated/misc.nix +++ b/lib/deprecated/misc.nix @@ -250,9 +250,9 @@ let # See https://github.com/NixOS/nixpkgs/pull/194391 for details. closePropagationFast = list: - builtins.map (x: x.val) ( + map (x: x.val) ( builtins.genericClosure { - startSet = builtins.map (x: { + startSet = map (x: { key = x.outPath; val = x; }) (builtins.filter (x: x != null) list); diff --git a/lib/fileset/tests.sh b/lib/fileset/tests.sh index 043c1156a43f0..78170ebc83914 100755 --- a/lib/fileset/tests.sh +++ b/lib/fileset/tests.sh @@ -1406,10 +1406,10 @@ echo '{ fs }: fs.toSource { root = ./.; fileset = fs.gitTracked ./.; }' > defaul git add . ## We can evaluate it locally just fine, `fetchGit` is used underneath to filter git-tracked files -expectEqual '(import ./. { fs = lib.fileset; }).outPath' '(builtins.fetchGit ./.).outPath' +expectEqual '(import ./. { fs = lib.fileset; }).outPath' '(fetchGit ./.).outPath' ## We can also evaluate when importing from fetched store paths -storePath=$(expectStorePath 'builtins.fetchGit ./.') +storePath=$(expectStorePath 'fetchGit ./.') expectEqual '(import '"$storePath"' { fs = lib.fileset; }).outPath' \""$storePath"\" ## But it fails if the path is imported with a fetcher that doesn't remove .git (like just using "${./.}") @@ -1429,13 +1429,13 @@ echo '{ fs }: fs.toSource { root = ./.; fileset = fs.gitTracked ./.; }' > sub/de git -C sub add . ## We can evaluate it locally just fine, `fetchGit` is used underneath to filter git-tracked files -expectEqual '(import ./. { fs = lib.fileset; }).outPath' '(builtins.fetchGit { url = ./.; submodules = true; }).outPath' -expectEqual '(import ./sub { fs = lib.fileset; }).outPath' '(builtins.fetchGit ./sub).outPath' +expectEqual '(import ./. { fs = lib.fileset; }).outPath' '(fetchGit { url = ./.; submodules = true; }).outPath' +expectEqual '(import ./sub { fs = lib.fileset; }).outPath' '(fetchGit ./sub).outPath' ## We can also evaluate when importing from fetched store paths -storePathWithSub=$(expectStorePath 'builtins.fetchGit { url = ./.; submodules = true; }') +storePathWithSub=$(expectStorePath 'fetchGit { url = ./.; submodules = true; }') expectEqual '(import '"$storePathWithSub"' { fs = lib.fileset; }).outPath' \""$storePathWithSub"\" -storePathSub=$(expectStorePath 'builtins.fetchGit ./sub') +storePathSub=$(expectStorePath 'fetchGit ./sub') expectEqual '(import '"$storePathSub"' { fs = lib.fileset; }).outPath' \""$storePathSub"\" ## But it fails if the path is imported with a fetcher that doesn't remove .git (like just using "${./.}") diff --git a/lib/gvariant.nix b/lib/gvariant.nix index e66217db81882..db2a33553ab7d 100644 --- a/lib/gvariant.nix +++ b/lib/gvariant.nix @@ -150,7 +150,7 @@ rec { ) intConstructors; in throw '' - The GVariant type for number “${builtins.toString v}” is unclear. + The GVariant type for number “${toString v}” is unclear. Please wrap the value with one of the following, depending on the value type in GSettings schema: ${lib.concatMapStringsSep "\n" ( diff --git a/lib/meta.nix b/lib/meta.nix index 85e800a7d8f67..d60cb9287e3e5 100644 --- a/lib/meta.nix +++ b/lib/meta.nix @@ -399,7 +399,7 @@ rec { => true lib.getLicenseFromSpdxIdOr "MY LICENSE" null => null - lib.getLicenseFromSpdxIdOr "MY LICENSE" (builtins.throw "No SPDX ID matches MY LICENSE") + lib.getLicenseFromSpdxIdOr "MY LICENSE" (throw "No SPDX ID matches MY LICENSE") => error: No SPDX ID matches MY LICENSE ``` ::: diff --git a/lib/strings.nix b/lib/strings.nix index 359e1a4cd8dbe..dcffacfcb420b 100644 --- a/lib/strings.nix +++ b/lib/strings.nix @@ -1135,7 +1135,7 @@ rec { "." "~" ]; - toEscape = builtins.removeAttrs asciiTable unreserved; + toEscape = removeAttrs asciiTable unreserved; in replaceStrings (builtins.attrNames toEscape) ( lib.mapAttrsToList (_: c: "%${fixedWidthString 2 "0" (lib.toHexString c)}") toEscape diff --git a/lib/systems/default.nix b/lib/systems/default.nix index 77247d269808e..54bc3c3fab0dc 100644 --- a/lib/systems/default.nix +++ b/lib/systems/default.nix @@ -75,7 +75,7 @@ let # Those two will always be derived from "config", if given, so they should NOT # be overridden further down with "// args". - args = builtins.removeAttrs allArgs [ + args = removeAttrs allArgs [ "parsed" "system" ]; diff --git a/lib/tests/checkAndMergeCompat.nix b/lib/tests/checkAndMergeCompat.nix index dc6f26fbf9173..f21c9789e8b64 100644 --- a/lib/tests/checkAndMergeCompat.nix +++ b/lib/tests/checkAndMergeCompat.nix @@ -326,7 +326,7 @@ in coerce_str_to_int_coercer_ouput = getMatrix { outerTypeName = "coercedTo"; innerTypeName = "int->str"; - getType = a: b: a.coercedTo b.int builtins.toString a.str; + getType = a: b: a.coercedTo b.int toString a.str; value = [ ]; testAttrs = { expectedError = { diff --git a/lib/tests/misc.nix b/lib/tests/misc.nix index a9c78defdffb3..e6252c17b67c9 100644 --- a/lib/tests/misc.nix +++ b/lib/tests/misc.nix @@ -4488,7 +4488,7 @@ runTests { expr = packagesFromDirectoryRecursive { callPackage = path: overrides: import path overrides; # Do NOT remove the `builtins.toString` call here!!! - directory = builtins.toString ./packages-from-directory/plain; + directory = toString ./packages-from-directory/plain; }; expected = { a = "a"; diff --git a/lib/tests/modules/declare-coerced-value-no-default.nix b/lib/tests/modules/declare-coerced-value-no-default.nix index 820913f920c35..cc929f9585b6f 100644 --- a/lib/tests/modules/declare-coerced-value-no-default.nix +++ b/lib/tests/modules/declare-coerced-value-no-default.nix @@ -3,7 +3,7 @@ { options = { value = lib.mkOption { - type = lib.types.coercedTo lib.types.int builtins.toString lib.types.str; + type = lib.types.coercedTo lib.types.int toString lib.types.str; }; }; } diff --git a/lib/tests/modules/declare-coerced-value.nix b/lib/tests/modules/declare-coerced-value.nix index 76b12ad53f00c..65a35669a2e8d 100644 --- a/lib/tests/modules/declare-coerced-value.nix +++ b/lib/tests/modules/declare-coerced-value.nix @@ -4,7 +4,7 @@ options = { value = lib.mkOption { default = 42; - type = lib.types.coercedTo lib.types.int builtins.toString lib.types.str; + type = lib.types.coercedTo lib.types.int toString lib.types.str; }; }; } diff --git a/lib/tests/modules/define-freeform-keywords-shorthand.nix b/lib/tests/modules/define-freeform-keywords-shorthand.nix index 3481cb52e5e34..9d0e8c871b4e9 100644 --- a/lib/tests/modules/define-freeform-keywords-shorthand.nix +++ b/lib/tests/modules/define-freeform-keywords-shorthand.nix @@ -9,7 +9,7 @@ _module.args.result = let - r = builtins.removeAttrs config [ "_module" ]; + r = removeAttrs config [ "_module" ]; in builtins.trace (builtins.deepSeq r r) ( r == { diff --git a/lib/trivial.nix b/lib/trivial.nix index 9c4deafb402c9..6a0fb87dc03b2 100644 --- a/lib/trivial.nix +++ b/lib/trivial.nix @@ -769,7 +769,7 @@ in importTOML :: path -> any ``` */ - importTOML = path: builtins.fromTOML (builtins.readFile path); + importTOML = path: fromTOML (builtins.readFile path); /** `warn` *`message`* *`value`* @@ -975,7 +975,7 @@ in unexpected = lib.subtractLists valid given; in lib.throwIfNot (unexpected == [ ]) - "${msg}: ${builtins.concatStringsSep ", " (builtins.map builtins.toString unexpected)} unexpected; valid ones: ${builtins.concatStringsSep ", " (builtins.map builtins.toString valid)}"; + "${msg}: ${builtins.concatStringsSep ", " (map toString unexpected)} unexpected; valid ones: ${builtins.concatStringsSep ", " (map toString valid)}"; info = msg: builtins.trace "INFO: ${msg}"; @@ -1144,7 +1144,7 @@ in match = builtins.match "(0x)?([0-7]?[0-9A-Fa-f]{1,15})" str; in if match != null then - (builtins.fromTOML "v=0x${builtins.elemAt match 1}").v + (fromTOML "v=0x${builtins.elemAt match 1}").v else # TODO: Turn this into a `throw` in 26.05. assert lib.warn "fromHexString: ${ @@ -1153,7 +1153,7 @@ in let noPrefix = lib.strings.removePrefix "0x" (lib.strings.toLower str); in - (builtins.fromTOML "v=0x${noPrefix}").v; + (fromTOML "v=0x${noPrefix}").v; /** Convert the given positive integer to a string of its hexadecimal diff --git a/lib/types.nix b/lib/types.nix index 1de5afef1be98..c23581c5281c1 100644 --- a/lib/types.nix +++ b/lib/types.nix @@ -1373,7 +1373,7 @@ let if builtins.isString v then ''"${v}"'' else if builtins.isInt v then - builtins.toString v + toString v else if builtins.isBool v then boolToString v else