Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/asserts.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/attrsets.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions lib/deprecated/misc.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 6 additions & 6 deletions lib/fileset/tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 "${./.}")
Expand All @@ -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 "${./.}")
Expand Down
2 changes: 1 addition & 1 deletion lib/gvariant.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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" (
Expand Down
2 changes: 1 addition & 1 deletion lib/meta.nix
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ rec {
=> true
lib.getLicenseFromSpdxIdOr "MY LICENSE" null
=> null
lib.getLicenseFromSpdxIdOr "MY LICENSE" (builtins.throw "No SPDX ID matches MY LICENSE")
Comment thread
philiptaron marked this conversation as resolved.
lib.getLicenseFromSpdxIdOr "MY LICENSE" (throw "No SPDX ID matches MY LICENSE")
=> error: No SPDX ID matches MY LICENSE
```
:::
Expand Down
2 changes: 1 addition & 1 deletion lib/strings.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/systems/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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"
];
Expand Down
2 changes: 1 addition & 1 deletion lib/tests/checkAndMergeCompat.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
2 changes: 1 addition & 1 deletion lib/tests/misc.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion lib/tests/modules/declare-coerced-value-no-default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
};
}
2 changes: 1 addition & 1 deletion lib/tests/modules/declare-coerced-value.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
};
}
2 changes: 1 addition & 1 deletion lib/tests/modules/define-freeform-keywords-shorthand.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 == {
Expand Down
8 changes: 4 additions & 4 deletions lib/trivial.nix
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ in
importTOML :: path -> any
```
*/
importTOML = path: builtins.fromTOML (builtins.readFile path);
importTOML = path: fromTOML (builtins.readFile path);
Comment thread
philiptaron marked this conversation as resolved.

/**
`warn` *`message`* *`value`*
Expand Down Expand Up @@ -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}";

Expand Down Expand Up @@ -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: ${
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/types.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading