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 machine.succeed("grep -E '/dev/vda / btrfs rw,relatime,space_cache=v2,subvolid=[0-9]+,subvol=/root 0 0' /proc/mounts")
86 machine.succeed("grep -E '/dev/vda /home btrfs rw,relatime,space_cache=v2,subvolid=[0-9]+,subvol=/home 0 0' /proc/mounts")
92 fsImage = "/tmp/non-default-filesystem.img";
95 name = "non-default-filesystems-erofs";
97 meta.maintainers = with maintainers; [ nikstur ];
100 virtualisation.qemu.drives = [{
101 name = "non-default-filesystem";
105 virtualisation.fileSystems."/non-default" = {
108 neededForBoot = true;
116 with tempfile.TemporaryDirectory() as tmp_dir:
117 with open(f"{tmp_dir}/filesystem", "w") as f:
121 "${pkgs.erofs-utils}/bin/mkfs.erofs",
127 machine.wait_for_unit("default.target")
129 file_contents = machine.succeed("cat /non-default/filesystem")
130 assert "erofs" in file_contents
136 fsImage = "/tmp/non-default-filesystem.img";
139 name = "non-default-filesystems-squashfs";
141 meta.maintainers = with maintainers; [ nikstur ];
144 virtualisation.qemu.drives = [{
145 name = "non-default-filesystem";
147 deviceExtraOpts.serial = "non-default";
150 virtualisation.fileSystems."/non-default" = {
151 device = "/dev/disk/by-id/virtio-non-default";
153 neededForBoot = true;
160 with open("filesystem", "w") as f:
164 "${pkgs.squashfsTools}/bin/mksquashfs",
169 assert "squashfs" in machine.succeed("cat /non-default/filesystem")