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,75 +1,81 @@
import ./make-test-python.nix ({ pkgs, ...} : {
name = "restart-by-activation-script";
meta = with pkgs.lib.maintainers; {
maintainers = [ das_j ];
};
nodes.machine = { pkgs, ... }: {
imports = [ ../modules/profiles/minimal.nix ];
system.switch.enable = true;
systemd.services.restart-me = {
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Type = "oneshot";
RemainAfterExit = true;
ExecStart = "${pkgs.coreutils}/bin/true";
};
import ./make-test-python.nix (
{ pkgs, ... }:
{
name = "restart-by-activation-script";
meta = with pkgs.lib.maintainers; {
maintainers = [ das_j ];
};
systemd.services.reload-me = {
wantedBy = [ "multi-user.target" ];
serviceConfig = rec {
Type = "oneshot";
RemainAfterExit = true;
ExecStart = "${pkgs.coreutils}/bin/true";
ExecReload = ExecStart;
};
};
nodes.machine =
{ pkgs, ... }:
{
imports = [ ../modules/profiles/minimal.nix ];
system.activationScripts.test = {
supportsDryActivation = true;
text = ''
if [ -e /test-the-activation-script ]; then
if [ "$NIXOS_ACTION" != dry-activate ]; then
touch /activation-was-run
echo restart-me.service > /run/nixos/activation-restart-list
echo reload-me.service > /run/nixos/activation-reload-list
else
echo restart-me.service > /run/nixos/dry-activation-restart-list
echo reload-me.service > /run/nixos/dry-activation-reload-list
fi
fi
system.switch.enable = true;
systemd.services.restart-me = {
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Type = "oneshot";
RemainAfterExit = true;
ExecStart = "${pkgs.coreutils}/bin/true";
};
};
systemd.services.reload-me = {
wantedBy = [ "multi-user.target" ];
serviceConfig = rec {
Type = "oneshot";
RemainAfterExit = true;
ExecStart = "${pkgs.coreutils}/bin/true";
ExecReload = ExecStart;
};
};
system.activationScripts.test = {
supportsDryActivation = true;
text = ''
if [ -e /test-the-activation-script ]; then
if [ "$NIXOS_ACTION" != dry-activate ]; then
touch /activation-was-run
echo restart-me.service > /run/nixos/activation-restart-list
echo reload-me.service > /run/nixos/activation-reload-list
else
echo restart-me.service > /run/nixos/dry-activation-restart-list
echo reload-me.service > /run/nixos/dry-activation-reload-list
fi
fi
'';
};
};
testScript = # python
''
machine.wait_for_unit("multi-user.target")
with subtest("nothing happens when the activation script does nothing"):
out = machine.succeed("/run/current-system/bin/switch-to-configuration dry-activate 2>&1")
assert 'restart' not in out
assert 'reload' not in out
out = machine.succeed("/run/current-system/bin/switch-to-configuration test")
assert 'restart' not in out
assert 'reload' not in out
machine.succeed("touch /test-the-activation-script")
with subtest("dry activation"):
out = machine.succeed("/run/current-system/bin/switch-to-configuration dry-activate 2>&1")
assert 'would restart the following units: restart-me.service' in out
assert 'would reload the following units: reload-me.service' in out
machine.fail("test -f /run/nixos/dry-activation-restart-list")
machine.fail("test -f /run/nixos/dry-activation-reload-list")
with subtest("real activation"):
out = machine.succeed("/run/current-system/bin/switch-to-configuration test 2>&1")
assert 'restarting the following units: restart-me.service' in out
assert 'reloading the following units: reload-me.service' in out
machine.fail("test -f /run/nixos/activation-restart-list")
machine.fail("test -f /run/nixos/activation-reload-list")
'';
};
};
testScript = /* python */ ''
machine.wait_for_unit("multi-user.target")
with subtest("nothing happens when the activation script does nothing"):
out = machine.succeed("/run/current-system/bin/switch-to-configuration dry-activate 2>&1")
assert 'restart' not in out
assert 'reload' not in out
out = machine.succeed("/run/current-system/bin/switch-to-configuration test")
assert 'restart' not in out
assert 'reload' not in out
machine.succeed("touch /test-the-activation-script")
with subtest("dry activation"):
out = machine.succeed("/run/current-system/bin/switch-to-configuration dry-activate 2>&1")
assert 'would restart the following units: restart-me.service' in out
assert 'would reload the following units: reload-me.service' in out
machine.fail("test -f /run/nixos/dry-activation-restart-list")
machine.fail("test -f /run/nixos/dry-activation-reload-list")
with subtest("real activation"):
out = machine.succeed("/run/current-system/bin/switch-to-configuration test 2>&1")
assert 'restarting the following units: restart-me.service' in out
assert 'reloading the following units: reload-me.service' in out
machine.fail("test -f /run/nixos/activation-restart-list")
machine.fail("test -f /run/nixos/activation-reload-list")
'';
})
}
)