Skip to content

Instantly share code, notes, and snippets.

@lheckemann
Created January 28, 2021 17:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save lheckemann/63c52f2115346e6c9bbc6ecdfde9f43b to your computer and use it in GitHub Desktop.
Save lheckemann/63c52f2115346e6c9bbc6ecdfde9f43b to your computer and use it in GitHub Desktop.
AArch64 VM
{ pkgsPath ? <nixpkgs> }:
let
pkgs = import pkgsPath {};
pkgsAarch64 = import pkgsPath { system = "aarch64-linux"; };
iso = (pkgsAarch64.nixos {
imports = [ (pkgsPath + "/nixos/modules/installer/cd-dvd/installation-cd-base.nix") ];
users.users.root.openssh.authorizedKeys.keyFiles = [(builtins.fetchurl https://github.com/lheckemann.keys)];
}).config.system.build.isoImage;
vmScript = pkgs.writeScript "run-nixos-vm" ''
#!${pkgs.runtimeShell}
${pkgs.qemu}/bin/qemu-system-aarch64 \
-machine virt,gic-version=max \
-cpu max \
-m 2G \
-smp 4 \
-drive file=$(echo ${iso}/iso/*.iso),format=raw,readonly=on \
-nographic \
-bios ${pkgsAarch64.OVMF.fd}/FV/QEMU_EFI.fd
'';
in vmScript
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment