Skip to content

Commit

Permalink
treewide: format all inactive Nix files
Browse files Browse the repository at this point in the history
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/77865e1ef7b097dc50195c5d622f2c9d0955785d.tar.gz \
      --argstr baseRev 9ad61cf
    result/bin/apply-formatting $NIXPKGS_PATH
  • Loading branch information
infinisil committed Dec 10, 2024
1 parent 9ad61cf commit 6fc80a3
Show file tree
Hide file tree
Showing 21,197 changed files with 705,258 additions and 432,647 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
22 changes: 14 additions & 8 deletions lib/tests/modules/submoduleFiles.nix
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
{ lib, ... }: {
{ lib, ... }:
{
options.submodule = lib.mkOption {
default = {};
default = { };
type = lib.types.submoduleWith {
modules = [ ({ options, ... }: {
options.value = lib.mkOption {};
modules = [
(
{ options, ... }:
{
options.value = lib.mkOption { };

options.internalFiles = lib.mkOption {
default = options.value.files;
};
})];
options.internalFiles = lib.mkOption {
default = options.value.files;
};
}
)
];
};
};

Expand Down
4 changes: 3 additions & 1 deletion lib/tests/modules/test-mergeAttrDefinitionsWithPrio.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

let
defs = lib.modules.mergeAttrDefinitionsWithPrio options._module.args;
assertLazy = pos: throw "${pos.file}:${toString pos.line}:${toString pos.column}: The test must not evaluate this the assertLazy thunk, but it did. Unexpected strictness leads to unexpected errors and performance problems.";
assertLazy =
pos:
throw "${pos.file}:${toString pos.line}:${toString pos.column}: The test must not evaluate this the assertLazy thunk, but it did. Unexpected strictness leads to unexpected errors and performance problems.";
in

{
Expand Down
3 changes: 2 additions & 1 deletion lib/tests/modules/types-anything/attrs-coercible.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{ lib, ... }: {
{ lib, ... }:
{

options.value = lib.mkOption {
type = lib.types.anything;
Expand Down
15 changes: 12 additions & 3 deletions lib/tests/modules/types-anything/equal-atoms.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{ lib, ... }: {
{ lib, ... }:
{

options.value = lib.mkOption {
type = lib.types.anything;
Expand All @@ -12,7 +13,11 @@
value.path = ./.;
value.null = null;
value.float = 0.1;
value.list = [1 "a" {x=null;}];
value.list = [
1
"a"
{ x = null; }
];
}
{
value.int = 0;
Expand All @@ -21,7 +26,11 @@
value.path = ./.;
value.null = null;
value.float = 0.1;
value.list = [1 "a" {x=null;}];
value.list = [
1
"a"
{ x = null; }
];
}
];

Expand Down
3 changes: 2 additions & 1 deletion lib/tests/modules/types-anything/functions.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{ lib, config, ... }: {
{ lib, config, ... }:
{

options.valueIsFunction = lib.mkOption {
default = lib.mapAttrs (name: lib.isFunction) config.value;
Expand Down
3 changes: 2 additions & 1 deletion lib/tests/modules/types-anything/lists.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{ lib, ... }: {
{ lib, ... }:
{

options.value = lib.mkOption {
type = lib.types.anything;
Expand Down
9 changes: 5 additions & 4 deletions lib/tests/modules/types-anything/mk-mods.nix
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
{ lib, ... }: {
{ lib, ... }:
{

options.value = lib.mkOption {
type = lib.types.anything;
};

config = lib.mkMerge [
{
value.mkiffalse = lib.mkIf false {};
value.mkiffalse = lib.mkIf false { };
}
{
value.mkiftrue = lib.mkIf true {};
value.mkiftrue = lib.mkIf true { };
}
{
value.mkdefault = lib.mkDefault 0;
Expand All @@ -19,7 +20,7 @@
}
{
value.mkmerge = lib.mkMerge [
{}
{ }
];
}
{
Expand Down
3 changes: 2 additions & 1 deletion lib/tests/modules/types-anything/nested-attrs.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{ lib, ... }: {
{ lib, ... }:
{

options.value = lib.mkOption {
type = lib.types.anything;
Expand Down
4 changes: 3 additions & 1 deletion lib/tests/modules/types-attrTag-wrong-decl.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ in
type = types.attrTag {
int = types.int;
};
default = { int = 1; };
default = {
int = 1;
};
};
};
}
63 changes: 48 additions & 15 deletions lib/tests/modules/types-attrTag.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
{ lib, config, options, ... }:
{
lib,
config,
options,
...
}:
let
inherit (lib) mkOption types;
forceDeep = x: builtins.deepSeq x x;
Expand All @@ -7,15 +12,16 @@ in
{
options = {
intStrings = mkOption {
type = types.attrsOf
(types.attrTag {
type = types.attrsOf (
types.attrTag {
left = mkOption {
type = types.int;
};
right = mkOption {
type = types.str;
};
});
}
);
};
nested = mkOption {
type = types.attrTag {
Expand Down Expand Up @@ -65,7 +71,7 @@ in
}
);
};
okChecks = mkOption {};
okChecks = mkOption { };
};
imports = [
./docs.nix
Expand All @@ -86,10 +92,19 @@ in
];
config = {
intStrings.syntaxError = 1;
intStrings.syntaxError2 = {};
intStrings.syntaxError3 = { a = true; b = true; };
intStrings.syntaxError4 = lib.mkMerge [ { a = true; } { b = true; } ];
intStrings.mergeError = lib.mkMerge [ { int = throw "do not eval"; } { string = throw "do not eval"; } ];
intStrings.syntaxError2 = { };
intStrings.syntaxError3 = {
a = true;
b = true;
};
intStrings.syntaxError4 = lib.mkMerge [
{ a = true; }
{ b = true; }
];
intStrings.mergeError = lib.mkMerge [
{ int = throw "do not eval"; }
{ string = throw "do not eval"; }
];
intStrings.badTagError.rite = throw "do not eval";
intStrings.badTagTypeError.left = "bad";
intStrings.numberOne.left = 1;
Expand All @@ -109,7 +124,12 @@ in
assert config.docs."submodules.<name>.foo.bar".type == "signed integer";
assert config.docs."submodules.<name>.qux".type == "string";
assert config.docs."submodules.<name>.qux".declarations == [ __curPos.file ];
assert config.docs."submodules.<name>.qux".loc == [ "submodules" "<name>" "qux" ];
assert
config.docs."submodules.<name>.qux".loc == [
"submodules"
"<name>"
"qux"
];
assert config.docs."submodules.<name>.qux".name == "submodules.<name>.qux";
assert config.docs."submodules.<name>.qux".description == "A qux for when you don't want a foo";
assert config.docs."submodules.<name>.qux".readOnly == false;
Expand All @@ -119,17 +139,30 @@ in
assert options.submodules.declarations == [ __curPos.file ];
assert lib.length options.submodules.declarationPositions == 1;
assert (lib.head options.submodules.declarationPositions).file == __curPos.file;
assert options.merged.declarations == [ __curPos.file __curPos.file ];
assert
options.merged.declarations == [
__curPos.file
__curPos.file
];
assert lib.length options.merged.declarationPositions == 2;
assert (lib.elemAt options.merged.declarationPositions 0).file == __curPos.file;
assert (lib.elemAt options.merged.declarationPositions 1).file == __curPos.file;
assert (lib.elemAt options.merged.declarationPositions 0).line != (lib.elemAt options.merged.declarationPositions 1).line;
assert mergedSubOption.declarations == [ __curPos.file __curPos.file ];
assert
(lib.elemAt options.merged.declarationPositions 0).line
!= (lib.elemAt options.merged.declarationPositions 1).line;
assert
mergedSubOption.declarations == [
__curPos.file
__curPos.file
];
assert lib.length mergedSubOption.declarationPositions == 2;
assert (lib.elemAt mergedSubOption.declarationPositions 0).file == __curPos.file;
assert (lib.elemAt mergedSubOption.declarationPositions 1).file == __curPos.file;
assert (lib.elemAt mergedSubOption.declarationPositions 0).line != (lib.elemAt mergedSubOption.declarationPositions 1).line;
assert
(lib.elemAt mergedSubOption.declarationPositions 0).line
!= (lib.elemAt mergedSubOption.declarationPositions 1).line;
assert lib.length config.docs."merged.<name>.extensible".declarations == 2;
true);
true
);
};
}
15 changes: 10 additions & 5 deletions lib/tests/modules/types-unique.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,18 @@ let
in
{
options.examples = mkOption {
type = types.lazyAttrsOf
(types.unique
{ message = "We require a single definition, because seeing the whole value at once helps us maintain critical invariants of our system."; }
(types.attrsOf types.str));
type = types.lazyAttrsOf (
types.unique {
message = "We require a single definition, because seeing the whole value at once helps us maintain critical invariants of our system.";
} (types.attrsOf types.str)
);
};
imports = [
{ examples.merged = { b = "bee"; }; }
{
examples.merged = {
b = "bee";
};
}
{ examples.override = lib.mkForce { b = "bee"; }; }
];
config.examples = {
Expand Down
11 changes: 5 additions & 6 deletions lib/tests/nix-for-tests.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{ pkgs
{
pkgs,
}:

# The aws-sdk-cpp tests are flaky. Since pull requests to staging
Expand All @@ -10,8 +11,6 @@
#
# See also: https://github.com/NixOS/nix/issues/7582

builtins.mapAttrs (_: pkg:
if builtins.isAttrs pkg
then pkg.override { withAWS = false; }
else pkg)
pkgs.nixVersions
builtins.mapAttrs (
_: pkg: if builtins.isAttrs pkg then pkg.override { withAWS = false; } else pkg
) pkgs.nixVersions
3 changes: 1 addition & 2 deletions lib/tests/packages-from-directory/a.nix
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
{ }:
"a"
{ }: "a"
3 changes: 1 addition & 2 deletions lib/tests/packages-from-directory/b.nix
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
{ }:
"b"
{ }: "b"
3 changes: 1 addition & 2 deletions lib/tests/packages-from-directory/c/package.nix
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
{ }:
"c"
{ }: "c"
3 changes: 1 addition & 2 deletions lib/tests/packages-from-directory/my-namespace/d.nix
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
{ }:
"d"
{ }: "d"
3 changes: 1 addition & 2 deletions lib/tests/packages-from-directory/my-namespace/e.nix
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
{ }:
"e"
{ }: "e"
3 changes: 1 addition & 2 deletions lib/tests/packages-from-directory/my-namespace/f/package.nix
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
{ }:
"f"
{ }: "f"
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
{ }:
"g"
{ }: "g"
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
{ }:
"h"
{ }: "h"
Loading

0 comments on commit 6fc80a3

Please sign in to comment.