treewide: format all inactive Nix files

After final improvements to the official formatter implementation,
this commit now performs the first treewide reformat of Nix files using it.
This is part of the implementation of RFC 166.

Only "inactive" files are reformatted, meaning only files that
aren't being touched by any PR with activity in the past 2 months.
This is to avoid conflicts for PRs that might soon be merged.
Later we can do a full treewide reformat to get the rest,
which should not cause as many conflicts.

A CI check has already been running for some time to ensure that new and
already-formatted files are formatted, so the files being reformatted here
should also stay formatted.

This commit was automatically created and can be verified using

    nix-build a08b3a4d19.tar.gz \
      --argstr baseRev b32a094368
    result/bin/apply-formatting $NIXPKGS_PATH
This commit is contained in:
Silvan Mosberger 2024-12-10 20:26:33 +01:00
parent b32a094368
commit 4f0dadbf38
21293 changed files with 701351 additions and 428307 deletions

View file

@ -26,7 +26,8 @@ let
generators
id
mapAttrs
trace;
trace
;
in
rec {
@ -36,7 +37,6 @@ rec {
/**
Conditionally trace the supplied message, based on a predicate.
# Inputs
`pred`
@ -70,15 +70,13 @@ rec {
:::
*/
traceIf =
pred:
msg:
x: if pred then trace msg x else x;
pred: msg: x:
if pred then trace msg x else x;
/**
Trace the supplied value after applying a function to it, and
return the original value.
# Inputs
`f`
@ -107,9 +105,7 @@ rec {
:::
*/
traceValFn =
f:
x: trace (f x) x;
traceValFn = f: x: trace (f x) x;
/**
Trace the supplied value and return it.
@ -143,7 +139,6 @@ rec {
/**
`builtins.trace`, but the value is `builtins.deepSeq`ed first.
# Inputs
`x`
@ -175,16 +170,13 @@ rec {
:::
*/
traceSeq =
x:
y: trace (builtins.deepSeq x x) y;
traceSeq = x: y: trace (builtins.deepSeq x x) y;
/**
Like `traceSeq`, but only evaluate down to depth n.
This is very useful because lots of `traceSeq` usages
lead to an infinite recursion.
# Inputs
`depth`
@ -217,25 +209,39 @@ rec {
:::
*/
traceSeqN = depth: x: y:
let snip = v: if isList v then noQuotes "[]" v
else if isAttrs v then noQuotes "{}" v
else v;
noQuotes = str: v: { __pretty = const str; val = v; };
modify = n: fn: v: if (n == 0) then fn v
else if isList v then map (modify (n - 1) fn) v
else if isAttrs v then mapAttrs
(const (modify (n - 1) fn)) v
else v;
in trace (generators.toPretty { allowPrettyValues = true; }
(modify depth snip x)) y;
traceSeqN =
depth: x: y:
let
snip =
v:
if isList v then
noQuotes "[]" v
else if isAttrs v then
noQuotes "{}" v
else
v;
noQuotes = str: v: {
__pretty = const str;
val = v;
};
modify =
n: fn: v:
if (n == 0) then
fn v
else if isList v then
map (modify (n - 1) fn) v
else if isAttrs v then
mapAttrs (const (modify (n - 1) fn)) v
else
v;
in
trace (generators.toPretty { allowPrettyValues = true; } (modify depth snip x)) y;
/**
A combination of `traceVal` and `traceSeq` that applies a
provided function to the value to be traced after `deepSeq`ing
it.
# Inputs
`f`
@ -246,9 +252,7 @@ rec {
: Value to trace
*/
traceValSeqFn =
f:
v: traceValFn f (builtins.deepSeq v v);
traceValSeqFn = f: v: traceValFn f (builtins.deepSeq v v);
/**
A combination of `traceVal` and `traceSeq`.
@ -258,7 +262,6 @@ rec {
`v`
: Value to trace
*/
traceValSeq = traceValSeqFn id;
@ -266,7 +269,6 @@ rec {
A combination of `traceVal` and `traceSeqN` that applies a
provided function to the value to be traced.
# Inputs
`f`
@ -282,9 +284,8 @@ rec {
: Value to trace
*/
traceValSeqNFn =
f:
depth:
v: traceSeqN depth (f v) v;
f: depth: v:
traceSeqN depth (f v) v;
/**
A combination of `traceVal` and `traceSeqN`.
@ -308,7 +309,6 @@ rec {
This is useful for adding around a function call,
to see the before/after of values as they are transformed.
# Inputs
`depth`
@ -327,7 +327,6 @@ rec {
: 4\. Function argument
# Examples
:::{.example}
## `lib.debug.traceFnSeqN` usage example
@ -340,17 +339,16 @@ rec {
:::
*/
traceFnSeqN = depth: name: f: v:
let res = f v;
in lib.traceSeqN
(depth + 1)
{
fn = name;
from = v;
to = res;
}
res;
traceFnSeqN =
depth: name: f: v:
let
res = f v;
in
lib.traceSeqN (depth + 1) {
fn = name;
from = v;
to = res;
} res;
# -- TESTING --
@ -375,7 +373,6 @@ rec {
- If you want to run only a subset of the tests add the attribute `tests = ["testName"];`
# Inputs
`tests`
@ -430,26 +427,42 @@ rec {
:::
*/
runTests =
tests: concatLists (attrValues (mapAttrs (name: test:
let testsToRun = if tests ? tests then tests.tests else [];
in if (substring 0 4 name == "test" || elem name testsToRun)
&& ((testsToRun == []) || elem name tests.tests)
&& (test.expr != test.expected)
tests:
concatLists (
attrValues (
mapAttrs (
name: test:
let
testsToRun = if tests ? tests then tests.tests else [ ];
in
if
(substring 0 4 name == "test" || elem name testsToRun)
&& ((testsToRun == [ ]) || elem name tests.tests)
&& (test.expr != test.expected)
then [ { inherit name; expected = test.expected; result = test.expr; } ]
else [] ) tests));
then
[
{
inherit name;
expected = test.expected;
result = test.expr;
}
]
else
[ ]
) tests
)
);
/**
Create a test assuming that list elements are `true`.
# Inputs
`expr`
: 1\. Function argument
# Examples
:::{.example}
## `lib.debug.testAllTrue` usage example
@ -460,5 +473,8 @@ rec {
:::
*/
testAllTrue = expr: { inherit expr; expected = map (x: true) expr; };
testAllTrue = expr: {
inherit expr;
expected = map (x: true) expr;
};
}