anchor.diff:  
       waitTill(){
         echo $1
  -      while ! eval "$2"; do sleep 1; done
  +      eval "while ! $2; do sleep 1; done"
       }
   
       SSH(){
  +      # if timout occurs ssh command will be retried.
  +      # Waiting forever doesn't seem to work because
  +      # there seems to be a race condition where
  +      # SSH connects but sshd doesn't notice it.
  +      # Thus fail and retry
         ssh -o UserKnownHostsFile=/dev/null \
           -o StrictHostKeyChecking=no \
           -o ProxyCommand="socat stdio ./$SOCKET_NAME" \
  +        -o ConnectTimeout=1 \
           root@127.0.0.1 \
           "$@";
       }
  
positive.code:     RUN_KVM -boot c
      waitForSSHD
  
  
      INFO "verifying that nix-env -i works"
  
      SSH_STDIN_E << EOF
  
        cat >> test.nix << EOF_TEST
        let pkgs = import /etc/nixos/nixpkgs/pkgs/top-level/all-packages.nix {};
        in pkgs.stdenv.mkDerivation {
          name = "test";
          phases = "create_out";
          create_out = "mkdir -p $out/ok";
        }
      EOF_TEST
  
        set -x
        nix-env -i -f test.nix
        [ -e ~/.nix-profile/ok ]
      EOF
  
      SHUTDOWN_VM
  
  
negative.code:     cat >> run-kvm.sh << EOF
      #!/bin/sh -e
  
      exec qemu-system-x86_64 -m 512 \
          -no-kvm-irqchip \
          -net nic,model=virtio -net user -smb /nix \
          -hda image \
          -redir tcp:''${SOCKET_NAME/.socket/}::22 \
          $KVM_OPTIONS \
          "\$@"
      EOF
      chmod +x run-kvm.sh
  