1 import ./make-test-python.nix ({pkgs, lib, ...}:
3 # A filesystem image with a (presumably) bootable debian
4 debianImage = pkgs.vmTools.diskImageFuns.debian11i386 {
5 # os-prober cannot detect systems installed on disks without a partition table
6 # so we create the disk ourselves
7 createRootFS = with pkgs; ''
8 ${parted}/bin/parted --script /dev/vda mklabel msdos
9 ${parted}/sbin/parted --script /dev/vda -- mkpart primary ext2 1M -1s
11 ${e2fsprogs}/bin/mkfs.ext4 -O '^metadata_csum_seed' /dev/vda1
12 ${util-linux}/bin/mount -t ext4 /dev/vda1 /mnt
14 if test -e /mnt/.debug; then
19 mkdir /mnt/proc /mnt/dev /mnt/sys
24 # make the disk bootable-looking
25 "grub2" "linux-image-686"
29 ln -sf /proc/self/mounts > /etc/mtab
30 PATH=/usr/bin:/bin:/usr/sbin:/sbin $chroot /mnt \
31 grub-install /dev/vda --force
32 PATH=/usr/bin:/bin:/usr/sbin:/sbin $chroot /mnt \
37 # a part of the configuration of the test vm
43 # vda is a filesystem without partition table
47 substituters = lib.mkForce [];
48 hashed-mirrors = null;
52 documentation.enable = false;
54 # /etc/nixos/configuration.nix for the vm
55 configFile = pkgs.writeText "configuration.nix" ''
56 {config, pkgs, lib, ...}: ({
58 [ ./hardware-configuration.nix
59 <nixpkgs/nixos/modules/testing/test-instrumentation.nix>
61 } // lib.importJSON ${
62 pkgs.writeText "simpleConfig.json" (builtins.toJSON simpleConfig)
68 nodes.machine = { config, pkgs, ... }: (simpleConfig // {
69 imports = [ ../modules/profiles/installation-device.nix
70 ../modules/profiles/base.nix ];
71 virtualisation.memorySize = 1300;
72 # To add the secondary disk:
73 virtualisation.qemu.options = [ "-drive index=2,file=${debianImage}/disk-image.qcow2,read-only,if=virtio" ];
75 # The test cannot access the network, so any packages
76 # nixos-rebuild needs must be included in the VM.
77 system.extraDependencies = with pkgs;
93 nixos-artwork.wallpapers.simple-dark-gray-bottom
95 perlPackages.ListCompare
96 perlPackages.XMLLibXML
105 # add curl so that rather than seeing the test attempt to download
106 # curl's tarball, we see what it's trying to download
113 machine.succeed("udevadm settle")
114 machine.wait_for_unit("multi-user.target")
115 print(machine.succeed("lsblk"))
117 # check that os-prober works standalone
119 "${pkgs.os-prober}/bin/os-prober | grep /dev/vdb1"
122 # rebuild and test that debian is available in the grub menu
123 machine.succeed("nixos-generate-config")
124 machine.copy_from_host(
126 "/etc/nixos/configuration.nix",
128 machine.succeed("nixos-rebuild boot --show-trace >&2")
130 machine.succeed("egrep 'menuentry.*debian' /boot/grub/grub.cfg")