New constraint between Release 19.09 and 20.03 in package qemu?

With the following two files vm.nix and vm-config.nix I am getting the error

#vm.nix
{ config, lib, pkgs, ... }:

with lib;

{
  imports =
    [ <nixpkgs/nixos/modules/installer/cd-dvd/channel.nix>
      <nixpkgs/nixos/modules/profiles/clone-config.nix>
      ./vm-config.nix
    ];

  system.build.qemuvmImage = import <nixpkgs/nixos/lib/make-disk-image.nix> {
    inherit lib config;
    pkgs = import <nixpkgs/nixos> { inherit (pkgs) system; }; # ensure we use the regular qemu-kvm package
    diskSize = 8192;
    format = "qcow2";
    configFile = pkgs.writeText "configuration.nix"
      ''
        {
          imports = [ <./machine-config.nix> ];
        }
      '';
    };
}
#vm-config.nix
{ pkgs, lib, ... }:

with lib;

{
  imports = [
    <nixpkgs/nixos/modules/profiles/qemu-guest.nix>
#    (import "${builtins.fetchTarball https://github.com/zimbatm/nixpkgs/archive/foldingathome.tar.gz}")
  ];

  config = {
    installer.cloneConfig = true;
    fileSystems."/" = {
      device = "/dev/disk/by-label/nixos";
      fsType = "ext4";
      autoResize = true;
    };

    # Set VM disk size (in MB)
    virtualisation.diskSize = 1024 * 2048;

    boot.growPartition = true;
    boot.kernelParams = [ "console=ttyS0 boot.shell_on_fail" ];
    boot.loader.grub.device = "/dev/vda";
    boot.loader.timeout = 0;

    i18n.defaultLocale = "de_DE.UTF-8";
    time.timeZone = "Europe/Paris";

    nixpkgs.config.allowUnfree = true;
    nixpkgs.config.allowUnsupportedSystem = true;
    nixpkgs.config.system-features = [ "kvm" "nixos-test" ];

    services = {
      timesyncd.enable = lib.mkDefault true;
      openssh = {
        enable = true;
        permitRootLogin = "yes";
      };

      # see https://github.com/NixOS/nixpkgs/pull/82192,
      #foldingAtHome = {
      #  enable = true;
      #  nickname = "Daniel";
      #};
    };

    environment.systemPackages = with pkgs; [
      #fahviewer fahcontrol
    ];

    users.extraUsers.root.password = "";
    users.mutableUsers = false;

    users.users.root = {
      extraGroups = [ "wheel" ];
    };
  };
}

qemu-system-x86_64: CPU model ‘host’ requires KVM

when using nix-build '<nixpkgs/nixos>' -A vm -I nixos-config=./vm.nix -I nixpkgs=channel:nixos-20.03-small instead of nix-build '<nixpkgs/nixos>' -A vm -I nixos-config=./vm.nix -I nixpkgs=channel:nixos-19.09-small and then ./result/bin/run-nixos-vm.

Is there a way to analyse this further ?

1 Like

I also ran into this. My initial investigation reveals that this might be suspect:

I haven’t yet tried to revert that commit and build an image with the old flag, but it certainly sounds like this would be the issue.

2 Likes

Ran into this issue while using nixos-generators to build a Digital Ocean image, I just tested it and reverting this commit does fix the issue.

1 Like

This fell off my radar, but for folks looking for a solution, this PR will fix it: https://github.com/NixOS/nixpkgs/pull/83920

3 Likes

The error is mentioned here as well.