|
4 | 4 | system, |
5 | 5 | perSystem, |
6 | 6 | ... |
7 | | -}: let |
| 7 | +}: |
| 8 | +let |
8 | 9 | # we have to import diskoLib like this because there are some impure default imports e.g. <nixpkgs> |
9 | 10 | diskoLib = import "${inputs.disko}/lib" { |
10 | 11 | inherit (pkgs) lib; |
11 | 12 | makeTest = import "${inputs.nixpkgs}/nixos/tests/make-test-python.nix"; |
12 | 13 | eval-config = import "${inputs.nixpkgs}/nixos/lib/eval-config.nix"; |
13 | 14 | }; |
14 | 15 | in |
15 | | - # for now we only run the tests in x86_64-linux since we don't have access to a bare-metal ARM box or a VM that supports nested |
16 | | - # virtualisation which makes the test take forever and ultimately fail |
17 | | - pkgs.lib.optionalAttrs pkgs.stdenv.isx86_64 { |
18 | | - golangci-lint = perSystem.self.nixos-facter.overrideAttrs (old: { |
19 | | - nativeBuildInputs = old.nativeBuildInputs ++ [pkgs.golangci-lint]; |
20 | | - buildPhase = '' |
21 | | - HOME=$TMPDIR |
22 | | - golangci-lint run |
23 | | - ''; |
24 | | - installPhase = '' |
25 | | - touch $out |
26 | | - ''; |
27 | | - doInstallCheck = false; |
28 | | - doCheck = false; |
29 | | - }); |
| 16 | +# for now we only run the tests in x86_64-linux since we don't have access to a bare-metal ARM box or a VM that supports nested |
| 17 | +# virtualisation which makes the test take forever and ultimately fail |
| 18 | +pkgs.lib.optionalAttrs pkgs.stdenv.isx86_64 { |
| 19 | + golangci-lint = perSystem.self.nixos-facter.overrideAttrs (old: { |
| 20 | + nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.golangci-lint ]; |
| 21 | + buildPhase = '' |
| 22 | + HOME=$TMPDIR |
| 23 | + golangci-lint run |
| 24 | + ''; |
| 25 | + installPhase = '' |
| 26 | + touch $out |
| 27 | + ''; |
| 28 | + doInstallCheck = false; |
| 29 | + doCheck = false; |
| 30 | + }); |
30 | 31 |
|
31 | | - basic = diskoLib.testLib.makeDiskoTest { |
32 | | - inherit pkgs; |
33 | | - name = "basic"; |
34 | | - disko-config = ./disko.nix; |
35 | | - extraSystemConfig = { |
36 | | - environment.systemPackages = [ |
37 | | - perSystem.self.nixos-facter |
38 | | - ]; |
39 | | - }; |
| 32 | + basic = diskoLib.testLib.makeDiskoTest { |
| 33 | + inherit pkgs; |
| 34 | + name = "basic"; |
| 35 | + disko-config = ./disko.nix; |
| 36 | + extraSystemConfig = { |
| 37 | + environment.systemPackages = [ |
| 38 | + perSystem.self.nixos-facter |
| 39 | + ]; |
| 40 | + }; |
40 | 41 |
|
41 | | - extraTestScript = '' |
42 | | - import json |
| 42 | + extraTestScript = '' |
| 43 | + import json |
43 | 44 |
|
44 | | - report = json.loads(machine.succeed("nixos-facter --ephemeral 2>&1")) |
| 45 | + report = json.loads(machine.succeed("nixos-facter --ephemeral 2>&1")) |
45 | 46 |
|
46 | | - with subtest("Capture system"): |
47 | | - assert report['system'] == '${system}' |
| 47 | + with subtest("Capture system"): |
| 48 | + assert report['system'] == '${system}' |
48 | 49 |
|
49 | | - with subtest("Capture virtualisation"): |
50 | | - virt = report['virtualisation'] |
51 | | - # kvm for systems that support it, otherwise the vm test should present itself as qemu |
52 | | - # todo double-check this is the same for intel |
53 | | - assert virt in ("kvm", "qemu"), f"expected virtualisation to be either kvm or qemu, got {virt}" |
| 50 | + with subtest("Capture virtualisation"): |
| 51 | + virt = report['virtualisation'] |
| 52 | + # kvm for systems that support it, otherwise the vm test should present itself as qemu |
| 53 | + # todo double-check this is the same for intel |
| 54 | + assert virt in ("kvm", "qemu"), f"expected virtualisation to be either kvm or qemu, got {virt}" |
54 | 55 |
|
55 | | - with subtest("Capture swap entries"): |
56 | | - assert 'swap' in report, "'swap' not found in the report" |
| 56 | + with subtest("Capture swap entries"): |
| 57 | + assert 'swap' in report, "'swap' not found in the report" |
57 | 58 |
|
58 | | - swap = report['swap'] |
| 59 | + swap = report['swap'] |
59 | 60 |
|
60 | | - expected = [ |
61 | | - { 'type': 'partition', 'size': 1048572, 'used': 0, 'priority': -2 }, |
62 | | - { 'type': 'partition', 'size': 10236, 'used': 0, 'priority': 100 } |
63 | | - ] |
| 61 | + expected = [ |
| 62 | + { 'type': 'partition', 'size': 1048572, 'used': 0, 'priority': -2 }, |
| 63 | + { 'type': 'partition', 'size': 10236, 'used': 0, 'priority': 100 } |
| 64 | + ] |
64 | 65 |
|
65 | | - assert len(swap) == len(expected), f"expected {len(expected)} swap entries, found {len(swap)}" |
| 66 | + assert len(swap) == len(expected), f"expected {len(expected)} swap entries, found {len(swap)}" |
66 | 67 |
|
67 | | - for i in range(2): |
68 | | - assert swap[i]['path'].startswith("/dev/disk/by-uuid/"), f"expected a stable device path: {swap[i]['path']}" |
| 68 | + for i in range(2): |
| 69 | + assert swap[i]['path'].startswith("/dev/disk/by-uuid/"), f"expected a stable device path: {swap[i]['path']}" |
69 | 70 |
|
70 | | - # delete for easier comparison |
71 | | - del swap[i]['path'] |
| 71 | + # delete for easier comparison |
| 72 | + del swap[i]['path'] |
72 | 73 |
|
73 | | - assert swap[i] == expected[i], "swap[{i}] mismatch" |
74 | | - ''; |
75 | | - }; |
76 | | - } |
| 74 | + assert swap[i] == expected[i], "swap[{i}] mismatch" |
| 75 | + ''; |
| 76 | + }; |
| 77 | +} |
0 commit comments