add qemu user emulation

This commit is contained in:
Gabriel Ebner 2018-12-18 17:30:45 +01:00
parent f04d990860
commit a655283b60
2 changed files with 30 additions and 0 deletions

@ -7,6 +7,7 @@
./large-sw.nix ./large-sw.nix
./uefi.nix ./uefi.nix
./fstrim.nix ./fstrim.nix
./qemu-user.nix
]; ];
environment.etc."lvm/lvm.conf".text = '' environment.etc."lvm/lvm.conf".text = ''

29
qemu-user.nix Normal file

@ -0,0 +1,29 @@
{ config, pkgs, lib, ... }:
let
arm = {
interpreter = "${pkgs.qemu}/bin/qemu-arm";
magicOrExtension = ''\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00'';
mask = ''\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\x00\xff\xfe\xff\xff\xff'';
};
aarch64 = {
interpreter = "${pkgs.qemu}/bin/qemu-aarch64";
magicOrExtension = ''\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7\x00'';
mask = ''\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\x00\xff\xfe\xff\xff\xff'';
};
riscv64 = {
interpreter = "${pkgs.qemu}/bin/qemu-riscv64";
magicOrExtension = ''\x7fELF\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf3\x00'';
mask = ''\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\x00\xff\xfe\xff\xff\xff'';
};
in {
boot.binfmtMiscRegistrations = {
inherit arm;
inherit aarch64;
inherit riscv64;
};
nix.extraOptions = ''
extra-platforms = armv6l-linux armv7l-linux aarch64-linux riscv64-linux i686-linux
'';
nix.sandboxPaths = [ "/run/binfmt" "${pkgs.qemu}" ];
}