# Run with : nix run -f tests.nix
# Debug with : nix -L run -f tests.nix driver -c nixos-test-driver
{ system ? builtins.currentSystem,
  config ? {},
  overlays ? nixpkgs/overlays.nix,
  pkgs ? import <nixpkgs> { inherit system config overlays; },
  lib ? pkgs.lib,
}:

let nixosTest =
  (import (pkgs.path + /nixos/lib/testing-python.nix)) {
    inherit system pkgs;
    extraConfigurations = [
      ({ lib, ... }: {
        # Propagate pkgs and its overlays to the VM,
        # instead of reloading nixpkgs.
        config.nixpkgs.pkgs = lib.mkDefault pkgs;
        config.documentation.enable = false;
      })
    ];
  };
in

nixosTest.makeTest {
  nodes = {
    mermet = {pkgs, ...}@attrs: {};
  };

  #enableOCR = true;
  #skipLint = true;
  testScript = ''
    # start_all()
    mermet.start()
    mermet.wait_for_unit("multi-user.target")
    mermet.succeed(
        "mkdir /tmp/test",
        "mount -t tmpfs none /tmp/test",
        "touch /tmp/test/hello",
        "test -f /tmp/test/hello",
    )
  '';
}