1

我正在尝试使用nixos-generators在安装了 nix 包管理器的 Ubuntu 机器中构建 AMI。我有这个配置:

$ cat configuration.nix
{ pkgs, ... }:

{
  imports = [ <nixpkgs/nixos/modules/virtualisation/amazon-image.nix> ];
  ec2.hvm = true;
  environment.systemPackages = with pkgs; [ git ];
}

然后我使用这个命令来创建一个 AMI:

$ nixos-generate -f amazon -c ./configuration.nix
these derivations will be built:
  /nix/store/zc68psb6kxz9sxqr82bqs7x6c3vamnbd-nixos-amazon-image-20.09pre-git-x86_64-linux.drv
error: a 'x86_64-linux' with features {kvm} is required to build '/nix/store/zc68psb6kxz9sxqr82bqs7x6c3vamnbd-nixos-amazon-image-20.09pre-git-x86_64-linux.drv', but I am a 'x86_64-linux' with features {benchmark, big-parallel, nixos-test}

您可以看到我得到的上述错误。我确实知道我的系统能够运行 KVM 虚拟机:

$ kvm-ok
INFO: /dev/kvm exists
KVM acceleration can be used

根据阅读文档,我填充了nix.conf这个:

$ cat ~/.config/nix/nix.conf
system-features = "kvm"

为此,我收到了这个奇怪的错误:

$ nixos-generate -f amazon -c ./configuration.nix
these derivations will be built:
  /nix/store/zc68psb6kxz9sxqr82bqs7x6c3vamnbd-nixos-amazon-image-20.09pre-git-x86_64-linux.drv
error: a 'x86_64-linux' with features {kvm} is required to build '/nix/store/zc68psb6kxz9sxqr82bqs7x6c3vamnbd-nixos-amazon-image-20.09pre-git-x86_64-linux.drv', but I am a 'x86_64-linux' with features {"kvm"}

关于如何解决此问题并构建 AMI 的任何想法?

4

1 回答 1

1

IRC 的@patogonicus 发现问题是nix.conf文件中的双引号:

system-features = kvm

它在该配置下运行良好。

于 2020-11-15T17:15:12.210 回答