anchor.diff:  
     passthru = {
       qemu-system-i386 = "bin/qemu-system-i386";
  +    tests = {
  +      qemu-tests = qemu.override { doCheck = true; };
  +    };
     };
   
     # Builds in ~3h with 2 cores, and ~20m with a big-parallel builder.
  
positive.code:                           ++ ["${stdenv.hostPlatform.qemuArch}-softmmu"])
                      else null)
  , nixosTestRunner ? false
  }:
  
  let
  
negative.code:   '';
    preBuild = "cd build";
  
    # tests can still timeout on slower systems
    inherit doCheck;
    checkInputs = [ socat ];
    preCheck = ''
      # time limits are a little meagre for a build machine that's
      # potentially under load.
      substituteInPlace ../tests/unit/meson.build \
        --replace 'timeout: slow_tests' 'timeout: 50 * slow_tests'
      substituteInPlace ../tests/qtest/meson.build \
        --replace 'timeout: slow_qtests' 'timeout: 50 * slow_qtests'
      substituteInPlace ../tests/fp/meson.build \
        --replace 'timeout: 90)' 'timeout: 300)'
  
      # point tests towards correct binaries
      substituteInPlace ../tests/unit/test-qga.c \
        --replace '/bin/echo' "$(type -P echo)"
      substituteInPlace ../tests/unit/test-io-channel-command.c \
        --replace '/bin/socat' "$(type -P socat)"
  
      # combined with a long package name, some temp socket paths
      # can end up exceeding max socket name len
      substituteInPlace ../tests/qtest/bios-tables-test.c \
        --replace 'qemu-test_acpi_%s_tcg_%s' '%s_%s'
  
      # get-fsinfo attempts to access block devices, disallowed by sandbox
      sed -i -e '/\/qga\/get-fsinfo/d' -e '/\/qga\/blacklist/d' \
        ../tests/unit/test-qga.c
    '' + lib.optionalString stdenv.isDarwin ''
      # skip test that stalls on darwin, perhaps due to subtle differences
      # in fifo behaviour
      substituteInPlace ../tests/unit/meson.build \
        --replace "'test-io-channel-command'" "#'test-io-channel-command'"
    '';
  
    # Add a ‘qemu-kvm’ wrapper for compatibility/convenience.
    postInstall = ''
      ln -s $out/bin/qemu-system-${stdenv.hostPlatform.qemuArch} $out/bin/qemu-kvm
  