{ config, lib, pkgs, inputs, ... }: let # Create pkgs with ensureZfsMounts overlay testPkgs = import inputs.nixpkgs { system = pkgs.system; overlays = [ (import ../overlays.nix) ]; }; in testPkgs.testers.runNixOSTest { name = "zfs folder dependency and mounting test"; nodes.machine = { pkgs, ... }: { imports = [ (lib.serviceMountDeps "foobar" [ "/mnt/foobar_data" ]) (lib.serviceMountDeps "foobarSadge" [ "/mnt/foobar_data" "/mnt/does_not_exist_lol" ]) ]; virtualisation = { emptyDiskImages = [ 4096 ]; useBootLoader = true; useEFIBoot = true; }; boot.loader.systemd-boot.enable = true; boot.loader.timeout = 0; boot.loader.efi.canTouchEfiVariables = true; networking.hostId = "deadbeef"; boot.kernelPackages = config.boot.kernelPackages; boot.zfs.package = config.boot.zfs.package; boot.supportedFilesystems = [ "zfs" ]; environment.systemPackages = [ pkgs.parted pkgs.ensureZfsMounts ]; systemd.services.foobar = { serviceConfig = { Type = "oneshot"; RemainAfterExit = true; ExecStart = "${lib.getExe pkgs.bash} -c \"true\""; }; }; systemd.services.foobarSadge = { serviceConfig = { Type = "oneshot"; RemainAfterExit = true; ExecStart = "${lib.getExe pkgs.bash} -c \"true\""; }; }; }; testScript = '' start_all() machine.wait_for_unit("multi-user.target") machine.succeed( "parted --script /dev/vdb mklabel msdos", "parted --script /dev/vdb -- mkpart primary 1024M -1s", ) machine.fail("zfsEnsureMounted") machine.fail("zfsEnsureMounted /mnt/test_mountpoint") machine.succeed("zpool create rpool /dev/vdb1") machine.succeed("zfs create -o mountpoint=/mnt/test_mountpoint rpool/test") machine.succeed("zfsEnsureMounted /mnt/test_mountpoint") machine.fail("zfsEnsureMounted /mnt/does_not_exist_lol") machine.fail("zfsEnsureMounted /mnt/test_mountpoint /mnt/does_not_exist_lol") machine.succeed("zfs create -o mountpoint=/mnt/test_mountpoint_dos rpool/test2") machine.succeed("zfsEnsureMounted /mnt/test_mountpoint /mnt/test_mountpoint_dos") machine.succeed("zfs create -o mountpoint='/mnt/test path with spaces' rpool/test3") machine.succeed("zfsEnsureMounted '/mnt/test path with spaces'") machine.succeed("echo 'ZFS output for escaped spaces:'; zfs list -o mountpoint,mounted -H | grep escaped") machine.succeed("zfsEnsureMounted /mnt/test\\ escaped\\ spaces") machine.succeed("zfsEnsureMounted /mnt/test_mountpoint '/mnt/test path with spaces' /mnt/test_mountpoint_dos") machine.succeed("zfs create -o mountpoint=/mnt/foobar_data rpool/foobar") machine.succeed("systemctl start foobar") machine.fail("systemctl start foobarSadge") ''; }