Skip to content

Commit 4f0dadb

Browse files
committed
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 https://github.com/infinisil/treewide-nixpkgs-reformat-script/archive/a08b3a4d199c6124ac5b36a889d9099b4383463f.tar.gz \ --argstr baseRev b32a094 result/bin/apply-formatting $NIXPKGS_PATH
1 parent b32a094 commit 4f0dadb

File tree

21,293 files changed

+706929
-433885
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

21,293 files changed

+706929
-433885
lines changed

default.nix

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
let requiredVersion = import ./lib/minver.nix; in
1+
let
2+
requiredVersion = import ./lib/minver.nix;
3+
in
24

3-
if ! builtins ? nixVersion || builtins.compareVersions requiredVersion builtins.nixVersion == 1 then
5+
if !builtins ? nixVersion || builtins.compareVersions requiredVersion builtins.nixVersion == 1 then
46

57
abort ''
68
+49-41
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,82 @@
1-
{ nixpkgsPath, revision, libsetsJSON }:
1+
{
2+
nixpkgsPath,
3+
revision,
4+
libsetsJSON,
5+
}:
26
let
37
lib = import (nixpkgsPath + "/lib");
48
libsets = builtins.fromJSON libsetsJSON;
59

6-
libDefPos = prefix: set:
7-
builtins.concatMap
8-
(name: [{
9-
name = builtins.concatStringsSep "." (prefix ++ [name]);
10-
location = builtins.unsafeGetAttrPos name set;
11-
}] ++ lib.optionals
12-
(builtins.length prefix == 0 && builtins.isAttrs set.${name})
13-
(libDefPos (prefix ++ [name]) set.${name})
14-
) (builtins.attrNames set);
10+
libDefPos =
11+
prefix: set:
12+
builtins.concatMap (
13+
name:
14+
[
15+
{
16+
name = builtins.concatStringsSep "." (prefix ++ [ name ]);
17+
location = builtins.unsafeGetAttrPos name set;
18+
}
19+
]
20+
++ lib.optionals (builtins.length prefix == 0 && builtins.isAttrs set.${name}) (
21+
libDefPos (prefix ++ [ name ]) set.${name}
22+
)
23+
) (builtins.attrNames set);
1524

16-
libset = toplib:
17-
builtins.map
18-
(subsetname: {
19-
subsetname = subsetname;
20-
functions = libDefPos [] toplib.${subsetname};
21-
})
22-
(builtins.map (x: x.name) libsets);
25+
libset =
26+
toplib:
27+
builtins.map (subsetname: {
28+
subsetname = subsetname;
29+
functions = libDefPos [ ] toplib.${subsetname};
30+
}) (builtins.map (x: x.name) libsets);
2331

24-
flattenedLibSubset = { subsetname, functions }:
25-
builtins.map
26-
(fn: {
32+
flattenedLibSubset =
33+
{ subsetname, functions }:
34+
builtins.map (fn: {
2735
name = "lib.${subsetname}.${fn.name}";
2836
value = fn.location;
29-
})
30-
functions;
37+
}) functions;
3138

3239
locatedlibsets = libs: builtins.map flattenedLibSubset (libset libs);
33-
removeFilenamePrefix = prefix: filename:
40+
removeFilenamePrefix =
41+
prefix: filename:
3442
let
35-
prefixLen = (builtins.stringLength prefix) + 1; # +1 to remove the leading /
43+
prefixLen = (builtins.stringLength prefix) + 1; # +1 to remove the leading /
3644
filenameLen = builtins.stringLength filename;
3745
substr = builtins.substring prefixLen filenameLen filename;
38-
in substr;
46+
in
47+
substr;
3948

4049
removeNixpkgs = removeFilenamePrefix (builtins.toString nixpkgsPath);
4150

42-
liblocations =
43-
builtins.filter
44-
(elem: elem.value != null)
45-
(lib.lists.flatten
46-
(locatedlibsets lib));
51+
liblocations = builtins.filter (elem: elem.value != null) (lib.lists.flatten (locatedlibsets lib));
4752

48-
fnLocationRelative = { name, value }:
53+
fnLocationRelative =
54+
{ name, value }:
4955
{
5056
inherit name;
51-
value = value // { file = removeNixpkgs value.file; };
57+
value = value // {
58+
file = removeNixpkgs value.file;
59+
};
5260
};
5361

5462
relativeLocs = (builtins.map fnLocationRelative liblocations);
55-
sanitizeId = builtins.replaceStrings
56-
[ "'" ]
57-
[ "-prime" ];
63+
sanitizeId = builtins.replaceStrings [ "'" ] [ "-prime" ];
5864

5965
urlPrefix = "https://github.com/NixOS/nixpkgs/blob/${revision}";
60-
jsonLocs = builtins.listToAttrs
61-
(builtins.map
62-
({ name, value }: {
66+
jsonLocs = builtins.listToAttrs (
67+
builtins.map (
68+
{ name, value }:
69+
{
6370
name = sanitizeId name;
6471
value =
6572
let
6673
text = "${value.file}:${builtins.toString value.line}";
6774
target = "${urlPrefix}/${value.file}#L${builtins.toString value.line}";
6875
in
69-
"[${text}](${target}) in `<nixpkgs>`";
70-
})
71-
relativeLocs);
76+
"[${text}](${target}) in `<nixpkgs>`";
77+
}
78+
) relativeLocs
79+
);
7280

7381
in
7482
jsonLocs

lib/ascii-table.nix

+95-94
Original file line numberDiff line numberDiff line change
@@ -1,99 +1,100 @@
1-
{ "\t" = 9;
1+
{
2+
"\t" = 9;
23
"\n" = 10;
34
"\r" = 13;
4-
" " = 32;
5-
"!" = 33;
5+
" " = 32;
6+
"!" = 33;
67
"\"" = 34;
7-
"#" = 35;
8-
"$" = 36;
9-
"%" = 37;
10-
"&" = 38;
11-
"'" = 39;
12-
"(" = 40;
13-
")" = 41;
14-
"*" = 42;
15-
"+" = 43;
16-
"," = 44;
17-
"-" = 45;
18-
"." = 46;
19-
"/" = 47;
20-
"0" = 48;
21-
"1" = 49;
22-
"2" = 50;
23-
"3" = 51;
24-
"4" = 52;
25-
"5" = 53;
26-
"6" = 54;
27-
"7" = 55;
28-
"8" = 56;
29-
"9" = 57;
30-
":" = 58;
31-
";" = 59;
32-
"<" = 60;
33-
"=" = 61;
34-
">" = 62;
35-
"?" = 63;
36-
"@" = 64;
37-
"A" = 65;
38-
"B" = 66;
39-
"C" = 67;
40-
"D" = 68;
41-
"E" = 69;
42-
"F" = 70;
43-
"G" = 71;
44-
"H" = 72;
45-
"I" = 73;
46-
"J" = 74;
47-
"K" = 75;
48-
"L" = 76;
49-
"M" = 77;
50-
"N" = 78;
51-
"O" = 79;
52-
"P" = 80;
53-
"Q" = 81;
54-
"R" = 82;
55-
"S" = 83;
56-
"T" = 84;
57-
"U" = 85;
58-
"V" = 86;
59-
"W" = 87;
60-
"X" = 88;
61-
"Y" = 89;
62-
"Z" = 90;
63-
"[" = 91;
8+
"#" = 35;
9+
"$" = 36;
10+
"%" = 37;
11+
"&" = 38;
12+
"'" = 39;
13+
"(" = 40;
14+
")" = 41;
15+
"*" = 42;
16+
"+" = 43;
17+
"," = 44;
18+
"-" = 45;
19+
"." = 46;
20+
"/" = 47;
21+
"0" = 48;
22+
"1" = 49;
23+
"2" = 50;
24+
"3" = 51;
25+
"4" = 52;
26+
"5" = 53;
27+
"6" = 54;
28+
"7" = 55;
29+
"8" = 56;
30+
"9" = 57;
31+
":" = 58;
32+
";" = 59;
33+
"<" = 60;
34+
"=" = 61;
35+
">" = 62;
36+
"?" = 63;
37+
"@" = 64;
38+
"A" = 65;
39+
"B" = 66;
40+
"C" = 67;
41+
"D" = 68;
42+
"E" = 69;
43+
"F" = 70;
44+
"G" = 71;
45+
"H" = 72;
46+
"I" = 73;
47+
"J" = 74;
48+
"K" = 75;
49+
"L" = 76;
50+
"M" = 77;
51+
"N" = 78;
52+
"O" = 79;
53+
"P" = 80;
54+
"Q" = 81;
55+
"R" = 82;
56+
"S" = 83;
57+
"T" = 84;
58+
"U" = 85;
59+
"V" = 86;
60+
"W" = 87;
61+
"X" = 88;
62+
"Y" = 89;
63+
"Z" = 90;
64+
"[" = 91;
6465
"\\" = 92;
65-
"]" = 93;
66-
"^" = 94;
67-
"_" = 95;
68-
"`" = 96;
69-
"a" = 97;
70-
"b" = 98;
71-
"c" = 99;
72-
"d" = 100;
73-
"e" = 101;
74-
"f" = 102;
75-
"g" = 103;
76-
"h" = 104;
77-
"i" = 105;
78-
"j" = 106;
79-
"k" = 107;
80-
"l" = 108;
81-
"m" = 109;
82-
"n" = 110;
83-
"o" = 111;
84-
"p" = 112;
85-
"q" = 113;
86-
"r" = 114;
87-
"s" = 115;
88-
"t" = 116;
89-
"u" = 117;
90-
"v" = 118;
91-
"w" = 119;
92-
"x" = 120;
93-
"y" = 121;
94-
"z" = 122;
95-
"{" = 123;
96-
"|" = 124;
97-
"}" = 125;
98-
"~" = 126;
66+
"]" = 93;
67+
"^" = 94;
68+
"_" = 95;
69+
"`" = 96;
70+
"a" = 97;
71+
"b" = 98;
72+
"c" = 99;
73+
"d" = 100;
74+
"e" = 101;
75+
"f" = 102;
76+
"g" = 103;
77+
"h" = 104;
78+
"i" = 105;
79+
"j" = 106;
80+
"k" = 107;
81+
"l" = 108;
82+
"m" = 109;
83+
"n" = 110;
84+
"o" = 111;
85+
"p" = 112;
86+
"q" = 113;
87+
"r" = 114;
88+
"s" = 115;
89+
"t" = 116;
90+
"u" = 117;
91+
"v" = 118;
92+
"w" = 119;
93+
"x" = 120;
94+
"y" = 121;
95+
"z" = 122;
96+
"{" = 123;
97+
"|" = 124;
98+
"}" = 125;
99+
"~" = 126;
99100
}

lib/asserts.nix

+10-20
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,7 @@ rec {
3636
:::
3737
*/
3838
# TODO(Profpatsch): add tests that check stderr
39-
assertMsg =
40-
pred:
41-
msg:
42-
pred || builtins.throw msg;
39+
assertMsg = pred: msg: pred || builtins.throw msg;
4340

4441
/**
4542
Specialized `assertMsg` for checking if `val` is one of the elements
@@ -81,14 +78,10 @@ rec {
8178
:::
8279
*/
8380
assertOneOf =
84-
name:
85-
val:
86-
xs:
87-
assertMsg
88-
(lib.elem val xs)
89-
"${name} must be one of ${
90-
lib.generators.toPretty {} xs}, but is: ${
91-
lib.generators.toPretty {} val}";
81+
name: val: xs:
82+
assertMsg (lib.elem val xs) "${name} must be one of ${lib.generators.toPretty { } xs}, but is: ${
83+
lib.generators.toPretty { } val
84+
}";
9285

9386
/**
9487
Specialized `assertMsg` for checking if every one of `vals` is one of the elements
@@ -133,12 +126,9 @@ rec {
133126
:::
134127
*/
135128
assertEachOneOf =
136-
name:
137-
vals:
138-
xs:
139-
assertMsg
140-
(lib.all (val: lib.elem val xs) vals)
141-
"each element in ${name} must be one of ${
142-
lib.generators.toPretty {} xs}, but is: ${
143-
lib.generators.toPretty {} vals}";
129+
name: vals: xs:
130+
assertMsg (lib.all (val: lib.elem val xs) vals)
131+
"each element in ${name} must be one of ${lib.generators.toPretty { } xs}, but is: ${
132+
lib.generators.toPretty { } vals
133+
}";
144134
}

0 commit comments

Comments
 (0)