1 import ./make-test-python.nix ({ pkgs, ... }: {
2 name = "nixos-rebuild-specialisations";
5 machine = { lib, pkgs, ... }: {
7 ../modules/profiles/installation-device.nix
8 ../modules/profiles/base.nix
12 substituters = lib.mkForce [ ];
13 hashed-mirrors = null;
17 system.includeBuildDependencies = true;
19 system.extraDependencies = [
20 # Not part of the initial build apparently?
24 system.switch.enable = true;
35 configFile = pkgs.writeText "configuration.nix" ''
38 ./hardware-configuration.nix
39 <nixpkgs/nixos/modules/testing/test-instrumentation.nix>
48 documentation.enable = false;
50 environment.systemPackages = [
51 (pkgs.writeShellScriptBin "parent" "")
54 specialisation.foo = {
55 inheritParentConfig = true;
57 configuration = { ... }: {
58 environment.systemPackages = [
59 (pkgs.writeShellScriptBin "foo" "")
64 specialisation.bar = {
65 inheritParentConfig = true;
67 configuration = { ... }: {
68 environment.systemPackages = [
69 (pkgs.writeShellScriptBin "bar" "")
79 machine.succeed("udevadm settle")
80 machine.wait_for_unit("multi-user.target")
82 machine.succeed("nixos-generate-config")
83 machine.copy_from_host(
85 "/etc/nixos/configuration.nix",
88 with subtest("Switch to the base system"):
89 machine.succeed("nixos-rebuild switch")
90 machine.succeed("parent")
94 with subtest("Switch from base system into a specialization"):
95 machine.succeed("nixos-rebuild switch --specialisation foo")
96 machine.succeed("parent")
97 machine.succeed("foo")
100 with subtest("Switch from specialization into another specialization"):
101 machine.succeed("nixos-rebuild switch -c bar")
102 machine.succeed("parent")
104 machine.succeed("bar")
106 with subtest("Switch from specialization into the base system"):
107 machine.succeed("nixos-rebuild switch")
108 machine.succeed("parent")
112 with subtest("Switch into specialization using `nixos-rebuild test`"):
113 machine.succeed("nixos-rebuild test --specialisation foo")
114 machine.succeed("parent")
115 machine.succeed("foo")
118 with subtest("Make sure nonsense command combinations are forbidden"):
119 machine.fail("nixos-rebuild boot --specialisation foo")
120 machine.fail("nixos-rebuild boot -c foo")