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

@@ -1,10 +1,11 @@
{ configuration ? import ../lib/from-env.nix "NIXOS_CONFIG" <nixos-config>
{
configuration ? import ../lib/from-env.nix "NIXOS_CONFIG" <nixos-config>,
# provide an option name, as a string literal.
, testOption ? null
# provide an option name, as a string literal.
testOption ? null,
# provide a list of option names, as string literals.
, testOptions ? [ ]
# provide a list of option names, as string literals.
testOptions ? [ ],
}:
# This file is made to be used as follow:
@@ -46,14 +47,16 @@ with import ../../lib;
let
evalFun = {
specialArgs ? {}
}: import ../lib/eval-config.nix {
modules = [ configuration ];
inherit specialArgs;
};
evalFun =
{
specialArgs ? { },
}:
import ../lib/eval-config.nix {
modules = [ configuration ];
inherit specialArgs;
};
eval = evalFun {};
eval = evalFun { };
inherit (eval) pkgs;
excludedTestOptions = [
@@ -79,21 +82,18 @@ let
"systemd.services"
"kde.extraPackages"
];
excludeOptions = list:
filter (opt: !(elem (showOption opt.loc) excludedOptions)) list;
excludeOptions = list: filter (opt: !(elem (showOption opt.loc) excludedOptions)) list;
reportNewFailures = old: new:
reportNewFailures =
old: new:
let
filterChanges =
filter ({fst, snd}:
!(fst.success -> snd.success)
);
filterChanges = filter ({ fst, snd }: !(fst.success -> snd.success));
keepNames =
map ({fst, snd}:
/* assert fst.name == snd.name; */ snd.name
);
keepNames = map (
{ fst, snd }:
# assert fst.name == snd.name;
snd.name
);
# Use tryEval (strict ...) to know if there is any failure while
# evaluating the option value.
@@ -101,16 +101,13 @@ let
# Note, the `strict` function is not strict enough, but using toXML
# builtins multiply by 4 the memory usage and the time used to compute
# each options.
tryCollectOptions = moduleResult:
forEach (excludeOptions (collect isOption moduleResult)) (opt:
{ name = showOption opt.loc; } // builtins.tryEval (strict opt.value));
in
keepNames (
filterChanges (
zipLists (tryCollectOptions old) (tryCollectOptions new)
)
);
tryCollectOptions =
moduleResult:
forEach (excludeOptions (collect isOption moduleResult)) (
opt: { name = showOption opt.loc; } // builtins.tryEval (strict opt.value)
);
in
keepNames (filterChanges (zipLists (tryCollectOptions old) (tryCollectOptions new)));
# Create a list of modules where each module contains only one failling
# options.
@@ -119,57 +116,55 @@ let
setIntrospection = opt: rec {
name = showOption opt.loc;
path = opt.loc;
config = setAttrByPath path
(throw "Usage introspection of '${name}' by forced failure.");
config = setAttrByPath path (throw "Usage introspection of '${name}' by forced failure.");
};
in
map setIntrospection (collect isOption eval.options);
map setIntrospection (collect isOption eval.options);
overrideConfig = thrower:
recursiveUpdateUntil (path: old: new:
overrideConfig =
thrower:
recursiveUpdateUntil (
path: old: new:
path == thrower.path
) eval.config thrower.config;
graph =
map (thrower: {
option = thrower.name;
usedBy = assert __trace "Investigate ${thrower.name}" true;
reportNewFailures eval.options (evalFun {
graph = map (thrower: {
option = thrower.name;
usedBy =
assert __trace "Investigate ${thrower.name}" true;
reportNewFailures eval.options
(evalFun {
specialArgs = {
config = overrideConfig thrower;
};
}).options;
}) introspectionModules;
}) introspectionModules;
displayOptionsGraph =
let
checkList =
if testOption != null then [ testOption ]
else testOptions;
checkAll = checkList == [];
in
flip filter graph ({option, ...}:
(checkAll || elem option checkList)
&& !(elem option excludedTestOptions)
);
let
checkList = if testOption != null then [ testOption ] else testOptions;
checkAll = checkList == [ ];
in
flip filter graph (
{ option, ... }: (checkAll || elem option checkList) && !(elem option excludedTestOptions)
);
graphToDot = graph: ''
digraph "Option Usages" {
${concatMapStrings ({option, usedBy}:
concatMapStrings (user: ''
"${option}" -> "${user}"''
) usedBy
) displayOptionsGraph}
${concatMapStrings (
{ option, usedBy }: concatMapStrings (user: ''"${option}" -> "${user}"'') usedBy
) displayOptionsGraph}
}
'';
graphToText = graph:
concatMapStrings ({usedBy, ...}:
concatMapStrings (user: ''
${user}
'') usedBy
) displayOptionsGraph;
graphToText =
graph:
concatMapStrings (
{ usedBy, ... }:
concatMapStrings (user: ''
${user}
'') usedBy
) displayOptionsGraph;
in

View File

@@ -1,10 +1,15 @@
let
pkgs = (import ../../../../../../default.nix {});
pkgs = (import ../../../../../../default.nix { });
machine = import (pkgs.path + "/nixos/lib/eval-config.nix") {
system = "x86_64-linux";
modules = [
({config, ...}: { imports = [ ./system.nix ]; })
(
{ config, ... }:
{
imports = [ ./system.nix ];
}
)
];
};
in
machine.config.system.build.azureImage
machine.config.system.build.azureImage

View File

@@ -1,6 +1,7 @@
{ pkgs, modulesPath, ... }:
let username = "azurenixosuser";
let
username = "azurenixosuser";
in
{
imports = [
@@ -28,6 +29,10 @@ in
security.sudo.wheelNeedsPassword = false;
environment.systemPackages = with pkgs; [
git file htop wget curl
git
file
htop
wget
curl
];
}

View File

@@ -1,20 +1,23 @@
# nix-build '<nixpkgs/nixos>' -A config.system.build.cloudstackImage --arg configuration "{ imports = [ ./nixos/maintainers/scripts/cloudstack/cloudstack-image.nix ]; }"
{ config, lib, pkgs, ... }:
{
config,
lib,
pkgs,
...
}:
{
imports =
[ ../../../modules/virtualisation/cloudstack-config.nix ];
imports = [ ../../../modules/virtualisation/cloudstack-config.nix ];
system.build.cloudstackImage = import ../../../lib/make-disk-image.nix {
inherit lib config pkgs;
format = "qcow2";
configFile = pkgs.writeText "configuration.nix"
''
{
imports = [ <nixpkgs/nixos/modules/virtualisation/cloudstack-config.nix> ];
}
'';
configFile = pkgs.writeText "configuration.nix" ''
{
imports = [ <nixpkgs/nixos/modules/virtualisation/cloudstack-config.nix> ];
}
'';
};
}

View File

@@ -5,13 +5,12 @@
{ modulesPath, ... }:
{
imports =
[
# Include the default lxd configuration.
"${modulesPath}/virtualisation/lxc-container.nix"
# Include the container-specific autogenerated configuration.
./lxd.nix
];
imports = [
# Include the default lxd configuration.
"${modulesPath}/virtualisation/lxc-container.nix"
# Include the container-specific autogenerated configuration.
./lxd.nix
];
networking = {
dhcpcd.enable = false;

View File

@@ -9,20 +9,25 @@
enable = true;
target = "/etc/nixos/lxd.nix";
template = ./nix.tpl;
when = [ "create" "copy" ];
when = [
"create"
"copy"
];
};
# copy the config for nixos-rebuild
system.activationScripts.config = let
config = pkgs.substituteAll {
src = ./lxd-container-image-inner.nix;
stateVersion = lib.trivial.release;
};
in ''
if [ ! -e /etc/nixos/configuration.nix ]; then
install -m 0644 -D ${config} /etc/nixos/configuration.nix
fi
'';
system.activationScripts.config =
let
config = pkgs.substituteAll {
src = ./lxd-container-image-inner.nix;
stateVersion = lib.trivial.release;
};
in
''
if [ ! -e /etc/nixos/configuration.nix ]; then
install -m 0644 -D ${config} /etc/nixos/configuration.nix
fi
'';
networking = {
dhcpcd.enable = false;

View File

@@ -5,13 +5,12 @@
{ modulesPath, ... }:
{
imports =
[
# Include the default lxd configuration.
"${modulesPath}/virtualisation/lxd-virtual-machine.nix"
# Include the container-specific autogenerated configuration.
./lxd.nix
];
imports = [
# Include the default lxd configuration.
"${modulesPath}/virtualisation/lxd-virtual-machine.nix"
# Include the container-specific autogenerated configuration.
./lxd.nix
];
networking = {
dhcpcd.enable = false;

View File

@@ -9,20 +9,25 @@
enable = true;
target = "/etc/nixos/lxd.nix";
template = ./nix.tpl;
when = ["create" "copy"];
when = [
"create"
"copy"
];
};
# copy the config for nixos-rebuild
system.activationScripts.config = let
config = pkgs.substituteAll {
src = ./lxd-virtual-machine-image-inner.nix;
stateVersion = lib.trivial.release;
};
in ''
if [ ! -e /etc/nixos/configuration.nix ]; then
install -m 0644 -D ${config} /etc/nixos/configuration.nix
fi
'';
system.activationScripts.config =
let
config = pkgs.substituteAll {
src = ./lxd-virtual-machine-image-inner.nix;
stateVersion = lib.trivial.release;
};
in
''
if [ ! -e /etc/nixos/configuration.nix ]; then
install -m 0644 -D ${config} /etc/nixos/configuration.nix
fi
'';
# Network
networking = {