{
  pkgs,
  ultracloudPackages,
  ultracloudModule,
}:

{
  name = "first-boot-topology-vm-smoke";

  nodes = {
    bridge01 =
      { ... }:
      {
        imports = [
          ultracloudModule
        ];

        networking.hostName = "bridge01";
        networking.firewall.enable = false;

        environment.systemPackages = with pkgs; [
          jq
        ];

        services.chainfire = {
          enable = true;
          package = ultracloudPackages.chainfire-server;
          nodeId = "bridge01";
          apiAddr = "127.0.0.1:2379";
          raftAddr = "127.0.0.1:2380";
          initialPeers = [ "bridge01=127.0.0.1:2380" ];
        };
        systemd.services.chainfire.environment.RUST_LOG = "error";

        services.first-boot-automation = {
          enable = true;
          enableFlareDB = false;
          enableIAM = false;
        };

        ultracloud.cluster = {
          enable = true;
          name = "bridge-cluster";
          nodes.bridge01 = {
            role = "control-plane";
            ip = "127.0.0.1";
            services = [ "chainfire" ];
            raftPort = 2380;
            apiPort = 2379;
          };
          bootstrap.initialPeers = [ "bridge01" ];
          bgp.asn = 64512;
        };

        system.stateVersion = "24.11";
      };
  };

  testScript = ''
    start_all()
    serial_stdout_off()

    machine = bridge01
    machine.wait_for_unit("chainfire.service")
    machine.wait_until_succeeds("test -f /etc/nixos/secrets/cluster-config.json")
    machine.succeed(
        "bash -lc 'systemctl restart chainfire-cluster-join.service "
        "|| (systemctl status chainfire-cluster-join.service --no-pager; "
        "journalctl -u chainfire-cluster-join.service --no-pager -n 200; exit 1)'"
    )
    machine.wait_until_succeeds("test -f /var/lib/first-boot-automation/.chainfire-initialized")
    machine.succeed("systemctl is-active chainfire-cluster-join.service")

    machine.succeed("jq -r '.node_id' /etc/nixos/secrets/cluster-config.json | grep -x 'bridge01'")
    machine.succeed("jq -r '.bootstrap' /etc/nixos/secrets/cluster-config.json | grep -x true")
    machine.succeed("jq -r '.cluster_name' /etc/nixos/secrets/cluster-config.json | grep -x 'bridge-cluster'")
    machine.succeed("jq -r '.chainfire_leader_url' /etc/nixos/secrets/cluster-config.json | grep -x 'http://127.0.0.1:8081'")
  '';
}
