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 57b193d8dd
    result/bin/apply-formatting $NIXPKGS_PATH
This commit is contained in:
Silvan Mosberger
2024-12-10 20:27:17 +01:00
parent 57b193d8dd
commit 667d42c00d
21287 changed files with 701385 additions and 428458 deletions

View File

@@ -2,15 +2,24 @@
with lib;
let
mergeFalseByDefault = locs: defs:
if defs == [] then abort "This case should never happen."
else if any (x: x == false) (getValues defs) then false
else true;
mergeFalseByDefault =
locs: defs:
if defs == [ ] then
abort "This case should never happen."
else if any (x: x == false) (getValues defs) then
false
else
true;
kernelItem = types.submodule {
options = {
tristate = mkOption {
type = types.enum [ "y" "m" "n" null ];
type = types.enum [
"y"
"m"
"n"
null
];
default = null;
internal = true;
visible = true;
@@ -31,7 +40,9 @@ let
};
optional = mkOption {
type = types.bool // { merge = mergeFalseByDefault; };
type = types.bool // {
merge = mergeFalseByDefault;
};
default = false;
description = ''
Whether option should generate a failure when unused.
@@ -41,17 +52,36 @@ let
};
};
mkValue = with lib; val:
let
isNumber = c: elem c ["0" "1" "2" "3" "4" "5" "6" "7" "8" "9"];
in
if (val == "") then "\"\""
else if val == "y" || val == "m" || val == "n" then val
else if all isNumber (stringToCharacters val) then val
else if substring 0 2 val == "0x" then val
else val; # FIXME: fix quoting one day
mkValue =
with lib;
val:
let
isNumber =
c:
elem c [
"0"
"1"
"2"
"3"
"4"
"5"
"6"
"7"
"8"
"9"
];
in
if (val == "") then
"\"\""
else if val == "y" || val == "m" || val == "n" then
val
else if all isNumber (stringToCharacters val) then
val
else if substring 0 2 val == "0x" then
val
else
val; # FIXME: fix quoting one day
# generate nix intermediate kernel config file of the form
#
@@ -64,19 +94,21 @@ let
# returns a string, expr should be an attribute set
# Use mkValuePreprocess to preprocess option values, aka mark 'modules' as 'yes' or vice-versa
# use the identity if you don't want to override the configured values
generateNixKConf = exprs:
let
mkConfigLine = key: item:
let
val = if item.freeform != null then item.freeform else item.tristate;
in
optionalString (val != null)
(if (item.optional)
then "${key}? ${mkValue val}\n"
else "${key} ${mkValue val}\n");
generateNixKConf =
exprs:
let
mkConfigLine =
key: item:
let
val = if item.freeform != null then item.freeform else item.tristate;
in
optionalString (val != null) (
if (item.optional) then "${key}? ${mkValue val}\n" else "${key} ${mkValue val}\n"
);
mkConf = cfg: concatStrings (mapAttrsToList mkConfigLine cfg);
in mkConf exprs;
mkConf = cfg: concatStrings (mapAttrsToList mkConfigLine cfg);
in
mkConf exprs;
in
{
@@ -99,11 +131,12 @@ in
settings = mkOption {
type = types.attrsOf kernelItem;
example = literalExpression '' with lib.kernel; {
"9P_NET" = yes;
USB = option yes;
MMC_BLOCK_MINORS = freeform "32";
}'';
example = literalExpression ''
with lib.kernel; {
"9P_NET" = yes;
USB = option yes;
MMC_BLOCK_MINORS = freeform "32";
}'';
description = ''
Structured kernel configuration.
'';