Closed 573 closed 2 years ago
Not sure what is going wrong on your device. This option definitely exists on 21.11: https://github.com/NixOS/nixpkgs/blob/17ee68bc368e175369258b97316328d6bca11d3b/nixos/modules/virtualisation/qemu-vm.nix#L306
I did as described in https://github.com/Mic92/nixos-shell#channelsnix_path
Then started nixos-shell as in
NIX_PATH=nixpkgs=channel:nixos-19.09-small make test
Reason:
/nix/store/qcsabcswq1sswl20nrnyi1i14zx24sp4-nixos-shell/bin/nixos-shell examples/vm.nix /nix/store/y5kvyby13kv6li8c1zaagmx0i651in9g-nixos-vm Could not access KVM kernel module: No such file or directory qemu-system-aarch64: failed to initialize kvm: No such file or directory
I want to circumvent this error by using the old channel. Does not seem to use the channel though.
With kvm disabled and 21.11 channel I got the same error message.
the virtualisation module in nixos uses qemu-kvm by default: https://github.com/NixOS/nixpkgs/blob/17ee68bc368e175369258b97316328d6bca11d3b/nixos/modules/virtualisation/qemu-vm.nix#L563 You would need to disable that if you want to use on a platform without kvm support.
diff --git a/examples/vm.nix b/examples/vm.nix
index 54480b8..9751765 100644
--- a/examples/vm.nix
+++ b/examples/vm.nix
@@ -1,4 +1,8 @@
{ pkgs, ... }: {
+ virtualisation.qemu = {
+ package = pkgs.qemu;
+ options = [ "-cpu max" ];
+ };
boot.kernelPackages = pkgs.linuxPackages_latest;
services.openssh.enable = true;
}
The error persists.
I'd have to replace the options differently I guess as they seem to not get picked up.
aarch64 seems to pass -enable-kvm regardless: https://github.com/NixOS/nixpkgs/blob/master/nixos/lib/qemu-common.nix#L27 This is a limitation that needs to be fixed in nixpkgs itself. It cannot be fixed in nixos-shell.
qemu-common-patched.nix:
aarch64-linux = "${qemuPkg}/bin/qemu-system-aarch64 -machine virt -cpu max";
changes in local copies of the files you linked, qemu-vm.nix importing the locally patched copy allow me to boot nixos-shell on https://github.com/t184256/nix-on-droid
NIXOS_EXTRA_MODULE_PATH=~/nixos-shell/qemu-vm.nix NIX_PATH=nixpkgs=file:///data/data/com.termux.nix/files/home/nixexprs.tar.xz nix-shell -p gnumake --run "bin/nixos-shell -v --show-trace examples/vm.nix"
diff --git a/examples/vm.nix b/examples/vm.nix
index 54480b8..d37f371 100644
--- a/examples/vm.nix
+++ b/examples/vm.nix
@@ -1,4 +1,11 @@
{ pkgs, ... }: {
boot.kernelPackages = pkgs.linuxPackages_latest;
services.openssh.enable = true;
+ nixos-shell = {
+ mounts = {
+ mountHome = false;
+ mountNixProfile = false;
+ cache = "none"; # default is "loose"
+ };
+ };
}
diff --git a/share/modules/nixos-shell.nix b/share/modules/nixos-shell.nix
index c0fec7a..e55365f 100644
--- a/share/modules/nixos-shell.nix
+++ b/share/modules/nixos-shell.nix
@@ -1,7 +1,7 @@
{ lib, options, pkgs, modulesPath, ... }:
{
- imports = [
+ disabledModules = [
"${toString modulesPath}/virtualisation/qemu-vm.nix"
];
"aarch64-linux"
Linux 4.4.111-21427293
no
no
nix-env (Nix) 2.3.16
"home-manager-21.11, nix-on-droid-21.11, nixpkgs-21.11.336020.2128d0aa28e"
/nix/store/3xxi7mfxzc2cr39z7slpiksl524aj9ma-nixexprs.tar.xz