1 { system ? builtins.currentSystem
3 , pkgs ? import ../.. { inherit system config; }
6 with import ../lib/testing-python.nix { inherit system pkgs; };
10 name = "non-default-filesystem-bind";
12 nodes.machine = { ... }: {
13 virtualisation.writableStore = false;
15 virtualisation.fileSystems."/test-bind-dir/bind" = {
21 virtualisation.fileSystems."/test-bind-file/bind" = {
22 depends = [ "/nix/store" ];
23 device = builtins.toFile "empty" "";
30 machine.wait_for_unit("multi-user.target")
36 name = "non-default-filesystems-btrfs";
39 { config, pkgs, lib, ... }:
41 disk = config.virtualisation.rootDevice;
44 virtualisation.rootDevice = "/dev/vda";
45 virtualisation.useDefaultFilesystems = false;
47 boot.initrd.availableKernelModules = [ "btrfs" ];
48 boot.supportedFilesystems = [ "btrfs" ];
50 boot.initrd.postDeviceCommands = ''
51 FSTYPE=$(blkid -o value -s TYPE ${disk} || true)
52 if test -z "$FSTYPE"; then
54 ${pkgs.btrfs-progs}/bin/mkfs.btrfs ${disk}
57 mount -t btrfs ${disk} /nixos
59 ${pkgs.btrfs-progs}/bin/btrfs subvolume create /nixos/root
60 ${pkgs.btrfs-progs}/bin/btrfs subvolume create /nixos/home
66 virtualisation.fileSystems = {
70 options = [ "subvol=/root" ];
76 options = [ "subvol=/home" ];
82 machine.wait_for_unit("multi-user.target")
84 with subtest("BTRFS filesystems are mounted correctly"):
85 print("output of \"grep -E '/dev/vda' /proc/mounts\":\n" + machine.execute("grep -E '/dev/vda' /proc/mounts")[1])
86 machine.succeed("grep -E '/dev/vda / btrfs rw,.*subvolid=[0-9]+,subvol=/root 0 0' /proc/mounts")
87 machine.succeed("grep -E '/dev/vda /home btrfs rw,.*subvolid=[0-9]+,subvol=/home 0 0' /proc/mounts")
93 fsImage = "/tmp/non-default-filesystem.img";
96 name = "non-default-filesystems-erofs";
98 meta.maintainers = with maintainers; [ nikstur ];
101 virtualisation.qemu.drives = [{
102 name = "non-default-filesystem";
106 virtualisation.fileSystems."/non-default" = {
109 neededForBoot = true;
117 with tempfile.TemporaryDirectory() as tmp_dir:
118 with open(f"{tmp_dir}/filesystem", "w") as f:
122 "${pkgs.erofs-utils}/bin/mkfs.erofs",
128 machine.wait_for_unit("default.target")
130 file_contents = machine.succeed("cat /non-default/filesystem")
131 assert "erofs" in file_contents
137 fsImage = "/tmp/non-default-filesystem.img";
140 name = "non-default-filesystems-squashfs";
142 meta.maintainers = with maintainers; [ nikstur ];
145 virtualisation.qemu.drives = [{
146 name = "non-default-filesystem";
148 deviceExtraOpts.serial = "non-default";
151 virtualisation.fileSystems."/non-default" = {
152 device = "/dev/disk/by-id/virtio-non-default";
154 neededForBoot = true;
161 with open("filesystem", "w") as f:
165 "${pkgs.squashfsTools}/bin/mksquashfs",
170 assert "squashfs" in machine.succeed("cat /non-default/filesystem")