anchor.diff:            ${pkgs.libvirt}/bin/virsh -c "${cfg.connectionURI}" \
               "${virshDestroyCmds}" &>/dev/null || true
             ${pkgs.libvirt}/bin/virsh -c "${cfg.connectionURI}" \
  -            "${virshCreateCmds}" >/dev/null
  +            "${virshCreateCmds}" >/dev/null || return
             ${pkgs.libvirt}/bin/virsh -c "${cfg.connectionURI}" \
               "event dom-$testid lifecycle --timeout ${toString cfg.timeouts.singleTryTimeout}" >/dev/null &
             export virshpid=$!
  
positive.code:             Type = "oneshot";
              ExecStart = "${pkgs.writeScriptBin "test-script" ''
                #!${bash}/bin/bash
                if "${cfg.test-driver.script}" >> log/stdout 2>> log/stderr; then
                  touch success
                else
                  touch failed
                fi
                sync -f .
                ${pkgs.systemd}/bin/systemctl poweroff --force
              ''}/bin/test-script";
            };
          };
  
negative.code:           wait $virshpid || true
          }
  
          uid="$(id -u)"
          gid="$(id -g)"
          pwd="$(pwd)"
          starttime="$(now)"
          retries_left="${toString cfg.retryCount}"
  
          while true; do
            try_starttime="$(now)"
            run_one_build || true
            log "Destroying libvirt machines"
            ${pkgs.libvirt}/bin/virsh -c "${cfg.connectionURI}" \
              "${virshDestroyCmds}" &>/dev/null || true
  
            try_time="$(($(now) - $try_starttime))"
            total_time="$(($(now) - $starttime))"
            retries_left="$(($retries_left - 1))"
  
            if (($total_time > ${toString cfg.timeouts.totalTimeout})); then
              err "Total build timeout passed"
              touch "$build/failed"
              break
            elif (($try_time > ${toString cfg.timeouts.singleTryTimeout})); then
              if ((retries_left <= 0)) && [ -z "${toString cfg.retryOnTimeout}"]; then
                err "Timeout, not retrying"
                touch "$build/failed"
                break
              fi
            elif ! [ -a "$build/script.status" ]; then
              if ((retries_left <= 0)); then
                err "Unknown result, no retries left"
                touch "$build/failed"
                break
              fi
            else
              case "$(cat "$build/script.status")" in
                0)
                  break
                  ;;
                2)
                  if ((retries_left <= 0)); then
                    err "Retries exhausted"
                    touch "$build/failed"
                    break
                  fi
                  ;;
                *)
                  err "Test script failed"
                  touch "$build/failed"
                  break
                  ;;
              esac
            fi
  
            log "Retrying build in ${toString cfg.timeouts.sleepBetweenRetries} seconds"
            sleep ${toString cfg.timeouts.sleepBetweenRetries}
          done
  