[Nix-dev] using qemu virtual machine for testing software

Tomasz Czyż tomasz.czyz at gmail.com
Fri Jul 29 02:40:37 CEST 2016


Hi,

I'm trying to use same mechanism as nixos for testing with vm.
I've created "run-vm.nix" and I can run vm with "nix-build run-vm.nix".

I can't connect to forwarded port and I don't know how to connect/interact
with the machine. Is there anyone who know how I could connect to this
machine and would be willing to explain?

run-vm.nix:

{system?builtins.currentSystem}:
let
  pkgs = import <nixpkgs> {};
  machine = {...}: {
      services.postgresql = {
          enable=true;
          enableTCPIP = true;
      };
      # networking.firewall.enable=false; # I've tried with this
   };
  testing = import <nixpkgs/nixos/lib/testing.nix>{inherit system;};
  test = testing.makeTest ({
    machine = machine;
    testScript=''
      $machine->start;
      $machine->waitForUnit("postgresql.service");
      $machine->waitForOpenPort(5432);
      $machine->forwardPort(9432, 5432);
      # $machine->forwardPort(5432, 9432); # I've tried with this as well
      # $machine->execute("sleep 9999999"); # I've tried with this as well
      $machine->waitForShutdown;
    '';
  });
in
    test
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.science.uu.nl/pipermail/nix-dev/attachments/20160729/54d4ee2d/attachment.html>


More information about the nix-dev mailing list