mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-09 19:13:26 +03:00

Format all Nix files using the officially approved formatter,
making the CI check introduced in the previous commit succeed:
nix-build ci -A fmt.check
This is the next step of the of the [implementation](https://github.com/NixOS/nixfmt/issues/153)
of the accepted [RFC 166](https://github.com/NixOS/rfcs/pull/166).
This commit will lead to merge conflicts for a number of PRs,
up to an estimated ~1100 (~33%) among the PRs with activity in the past 2
months, but that should be lower than what it would be without the previous
[partial treewide format](https://github.com/NixOS/nixpkgs/pull/322537).
Merge conflicts caused by this commit can now automatically be resolved while rebasing using the
[auto-rebase script](8616af08d9/maintainers/scripts/auto-rebase
).
If you run into any problems regarding any of this, please reach out to the
[formatting team](https://nixos.org/community/teams/formatting/) by
pinging @NixOS/nix-formatting.
140 lines
3.8 KiB
Nix
140 lines
3.8 KiB
Nix
{
|
|
hostPkgs,
|
|
lib,
|
|
withNg,
|
|
...
|
|
}:
|
|
{
|
|
name = "nixos-rebuild-specialisations";
|
|
|
|
# TODO: remove overlay from nixos/modules/profiles/installation-device.nix
|
|
# make it a _small package instead, then remove pkgsReadOnly = false;.
|
|
node.pkgsReadOnly = false;
|
|
|
|
nodes = {
|
|
machine =
|
|
{ lib, pkgs, ... }:
|
|
{
|
|
imports = [
|
|
../modules/profiles/installation-device.nix
|
|
../modules/profiles/base.nix
|
|
];
|
|
|
|
nix.settings = {
|
|
substituters = lib.mkForce [ ];
|
|
hashed-mirrors = null;
|
|
connect-timeout = 1;
|
|
};
|
|
|
|
system.includeBuildDependencies = true;
|
|
|
|
system.extraDependencies = [
|
|
# Not part of the initial build apparently?
|
|
pkgs.grub2
|
|
];
|
|
|
|
system.rebuild.enableNg = withNg;
|
|
system.switch.enable = true;
|
|
|
|
virtualisation = {
|
|
cores = 2;
|
|
memorySize = 4096;
|
|
};
|
|
};
|
|
};
|
|
|
|
testScript =
|
|
let
|
|
configFile =
|
|
hostPkgs.writeText "configuration.nix" # nix
|
|
''
|
|
{ lib, pkgs, ... }: {
|
|
imports = [
|
|
./hardware-configuration.nix
|
|
<nixpkgs/nixos/modules/testing/test-instrumentation.nix>
|
|
];
|
|
|
|
boot.loader.grub = {
|
|
enable = true;
|
|
device = "/dev/vda";
|
|
forceInstall = true;
|
|
};
|
|
|
|
documentation.enable = false;
|
|
|
|
environment.systemPackages = [
|
|
(pkgs.writeShellScriptBin "parent" "")
|
|
];
|
|
|
|
system.rebuild.enableNg = ${lib.boolToString withNg};
|
|
|
|
specialisation.foo = {
|
|
inheritParentConfig = true;
|
|
|
|
configuration = { ... }: {
|
|
environment.systemPackages = [
|
|
(pkgs.writeShellScriptBin "foo" "")
|
|
];
|
|
};
|
|
};
|
|
|
|
specialisation.bar = {
|
|
inheritParentConfig = true;
|
|
|
|
configuration = { ... }: {
|
|
environment.systemPackages = [
|
|
(pkgs.writeShellScriptBin "bar" "")
|
|
];
|
|
};
|
|
};
|
|
}
|
|
'';
|
|
|
|
in
|
|
# python
|
|
''
|
|
machine.start()
|
|
machine.succeed("udevadm settle")
|
|
machine.wait_for_unit("multi-user.target")
|
|
|
|
machine.succeed("nixos-generate-config")
|
|
machine.copy_from_host(
|
|
"${configFile}",
|
|
"/etc/nixos/configuration.nix",
|
|
)
|
|
|
|
with subtest("Switch to the base system"):
|
|
machine.succeed("nixos-rebuild switch")
|
|
machine.succeed("parent")
|
|
machine.fail("foo")
|
|
machine.fail("bar")
|
|
|
|
with subtest("Switch from base system into a specialization"):
|
|
machine.succeed("nixos-rebuild switch --specialisation foo")
|
|
machine.succeed("parent")
|
|
machine.succeed("foo")
|
|
machine.fail("bar")
|
|
|
|
with subtest("Switch from specialization into another specialization"):
|
|
machine.succeed("nixos-rebuild switch -c bar")
|
|
machine.succeed("parent")
|
|
machine.fail("foo")
|
|
machine.succeed("bar")
|
|
|
|
with subtest("Switch from specialization into the base system"):
|
|
machine.succeed("nixos-rebuild switch")
|
|
machine.succeed("parent")
|
|
machine.fail("foo")
|
|
machine.fail("bar")
|
|
|
|
with subtest("Switch into specialization using `nixos-rebuild test`"):
|
|
machine.succeed("nixos-rebuild test --specialisation foo")
|
|
machine.succeed("parent")
|
|
machine.succeed("foo")
|
|
machine.fail("bar")
|
|
|
|
with subtest("Make sure nonsense command combinations are forbidden"):
|
|
machine.fail("nixos-rebuild boot --specialisation foo")
|
|
machine.fail("nixos-rebuild boot -c foo")
|
|
'';
|
|
}
|