at 23.05-pre 1.5 kB view raw
1import ./make-test-python.nix ({ lib, pkgs, ... }: 2{ 3 name = "non-default-filesystems"; 4 5 nodes.machine = 6 { config, pkgs, lib, ... }: 7 let 8 disk = config.virtualisation.bootDevice; 9 in 10 { 11 virtualisation.useDefaultFilesystems = false; 12 13 boot.initrd.availableKernelModules = [ "btrfs" ]; 14 boot.supportedFilesystems = [ "btrfs" ]; 15 16 boot.initrd.postDeviceCommands = '' 17 FSTYPE=$(blkid -o value -s TYPE ${disk} || true) 18 if test -z "$FSTYPE"; then 19 modprobe btrfs 20 ${pkgs.btrfs-progs}/bin/mkfs.btrfs ${disk} 21 22 mkdir /nixos 23 mount -t btrfs ${disk} /nixos 24 25 ${pkgs.btrfs-progs}/bin/btrfs subvolume create /nixos/root 26 ${pkgs.btrfs-progs}/bin/btrfs subvolume create /nixos/home 27 28 umount /nixos 29 fi 30 ''; 31 32 virtualisation.fileSystems = { 33 "/" = { 34 device = disk; 35 fsType = "btrfs"; 36 options = [ "subvol=/root" ]; 37 }; 38 39 "/home" = { 40 device = disk; 41 fsType = "btrfs"; 42 options = [ "subvol=/home" ]; 43 }; 44 }; 45 }; 46 47 testScript = '' 48 machine.wait_for_unit("multi-user.target") 49 50 with subtest("BTRFS filesystems are mounted correctly"): 51 machine.succeed("grep -E '/dev/vda / btrfs rw,relatime,space_cache=v2,subvolid=[0-9]+,subvol=/root 0 0' /proc/mounts") 52 machine.succeed("grep -E '/dev/vda /home btrfs rw,relatime,space_cache=v2,subvolid=[0-9]+,subvol=/home 0 0' /proc/mounts") 53 ''; 54})