summary refs log tree commit diff
path: root/nixos/modules/virtualisation/qemu-vm.nix
diff options
context:
space:
mode:
authorTuomas Tynkkynen <tuomas.tynkkynen@iki.fi>2017-11-24 14:31:50 +0200
committerTuomas Tynkkynen <tuomas.tynkkynen@iki.fi>2017-11-26 11:13:21 +0200
commite56da6a4642c843d7ba88f513840da7d473eecec (patch)
treec1ab418ccbdac349c8e18da91d6731029d53d03d /nixos/modules/virtualisation/qemu-vm.nix
parent0a2eda7a7e3cf7eadb0401f07071e1a3c22a4675 (diff)
downloadnixpkgs-e56da6a4642c843d7ba88f513840da7d473eecec.tar
nixpkgs-e56da6a4642c843d7ba88f513840da7d473eecec.tar.gz
nixpkgs-e56da6a4642c843d7ba88f513840da7d473eecec.tar.bz2
nixpkgs-e56da6a4642c843d7ba88f513840da7d473eecec.tar.lz
nixpkgs-e56da6a4642c843d7ba88f513840da7d473eecec.tar.xz
nixpkgs-e56da6a4642c843d7ba88f513840da7d473eecec.tar.zst
nixpkgs-e56da6a4642c843d7ba88f513840da7d473eecec.zip
nixos/qemu-vm: Use different serial port on ARM/AArch64
Diffstat (limited to 'nixos/modules/virtualisation/qemu-vm.nix')
-rw-r--r--nixos/modules/virtualisation/qemu-vm.nix7
1 files changed, 6 insertions, 1 deletions
diff --git a/nixos/modules/virtualisation/qemu-vm.nix b/nixos/modules/virtualisation/qemu-vm.nix
index 3f10180cd1c..770e5fb848a 100644
--- a/nixos/modules/virtualisation/qemu-vm.nix
+++ b/nixos/modules/virtualisation/qemu-vm.nix
@@ -21,6 +21,11 @@ let
     "aarch64-linux" = "${qemu}/bin/qemu-system-aarch64 -enable-kvm -machine virt -cpu host";
   }.${pkgs.stdenv.system};
 
+  # FIXME: figure out a common place for this instead of copy pasting
+  serialDevice = if pkgs.stdenv.isi686 || pkgs.stdenv.isx86_64 then "ttyS0"
+        else if pkgs.stdenv.isArm || pkgs.stdenv.isAarch64 then "ttyAMA0"
+        else throw "Unknown QEMU serial device for system '${pkgs.stdenv.system}'";
+
   vmName =
     if config.networking.hostName == ""
     then "noname"
@@ -29,7 +34,7 @@ let
   cfg = config.virtualisation;
 
   qemuGraphics = if cfg.graphics then "" else "-nographic";
-  kernelConsole = if cfg.graphics then "" else "console=ttyS0";
+  kernelConsole = if cfg.graphics then "" else "console=${serialDevice}";
   ttys = [ "tty1" "tty2" "tty3" "tty4" "tty5" "tty6" ];
 
   # Shell script to start the VM.