check
This commit is contained in:
@@ -24,6 +24,8 @@ in
|
||||
config = mkIf cfg.enable {
|
||||
boot = {
|
||||
|
||||
kernelModules = [ "kvm" ];
|
||||
|
||||
binfmt = lib.mkIf isArm {
|
||||
registrations."x86_64-linux" = {
|
||||
magicOrExtension = ''\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x3e\x00'';
|
||||
|
||||
@@ -186,6 +186,11 @@ in
|
||||
useGenerationDeviceTree = lib.mkOverride 60 (if cfg.bootType == "uefi" then false else true);
|
||||
};
|
||||
systemd-boot.enable = (if cfg.bootType == "uefi" then true else false);
|
||||
systemd-boot.extraInstallCommands = let
|
||||
bootloaderInstaller = (if cfg.bootType == "uefi" then (builder."uefi") else (builder."uboot")); # todo
|
||||
in ''
|
||||
${bootloaderInstaller} -f /boot/firmware -b /boot -c
|
||||
'';
|
||||
grub.enable = lib.mkForce false;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -42,9 +42,8 @@ if [ -n "$fwtarget" ]; then
|
||||
@firmwareBuilder@ -c $default -d $fwtarget
|
||||
|
||||
echo "copying uefi firmware..."
|
||||
#for file in "@uefi@/*"; do
|
||||
rm -rf $fwtarget/*
|
||||
copyForced @uefi@ $fwtarget/
|
||||
#done
|
||||
fi
|
||||
|
||||
echo "uefi bootloader installed"
|
||||
|
||||
74
qemu.nix
74
qemu.nix
@@ -1,25 +1,67 @@
|
||||
with import <nixpkgs> { };
|
||||
{ pkgs ? import <nixpkgs> {} }:
|
||||
|
||||
writeShellApplication {
|
||||
pkgs.writeShellApplication {
|
||||
name = "test-image";
|
||||
runtimeInputs = [ qemu ];
|
||||
runtimeInputs = [
|
||||
pkgs.qemu
|
||||
pkgs.OVMF
|
||||
];
|
||||
text = ''
|
||||
if [ -z "$1" ]; then
|
||||
echo "Usage: $0 <path-to-boot-image>"
|
||||
set -euo pipefail
|
||||
|
||||
if [ $# -lt 1 ]; then
|
||||
echo "Usage: $0 <path-to-boot-image> [x86_64|aarch64]" >&2
|
||||
exit 1
|
||||
fi
|
||||
tmpFile=$(mktemp /home/matt/tmp/test-image.XXXXXX)
|
||||
trap 'rm -f $tmpFile' EXIT
|
||||
cp "$1" "$tmpFile"
|
||||
qemu-system-x86_64 \
|
||||
-enable-kvm \
|
||||
-m 4G \
|
||||
-cpu max \
|
||||
-smp 4 \
|
||||
|
||||
img="$1"
|
||||
arch="''\${2:-$(uname -m)}"
|
||||
|
||||
accel=( -accel kvm )
|
||||
[ -e /dev/kvm ] || accel=( -accel "tcg,thread=multi" )
|
||||
|
||||
case "$arch" in
|
||||
x86_64|amd64)
|
||||
qemu_bin="qemu-system-x86_64"
|
||||
machine=( -machine q35 )
|
||||
cpu=( -cpu max )
|
||||
smp=( -smp 4 )
|
||||
ram=( -m 4G )
|
||||
pflash_code=( -drive "if=pflash,format=raw,readonly=on,file=${pkgs.OVMF.firmware}" )
|
||||
pflash_vars=( -drive "if=pflash,format=raw,readonly=on,file=${pkgs.OVMF.variables}" )
|
||||
;;
|
||||
aarch64|arm64)
|
||||
qemu_bin="qemu-system-aarch64"
|
||||
machine=( -machine virt )
|
||||
cpu=( -cpu host )
|
||||
smp=( -smp 4 )
|
||||
ram=( -m 4G )
|
||||
# Copy VARS to a writable temp file; QEMU opens it read/write
|
||||
varsTmp=$(mktemp /tmp/AAVMF_VARS.fd.XXXXXX)
|
||||
cp ${pkgs.OVMF.fd}/FV/AAVMF_VARS.fd "$varsTmp"
|
||||
pflash_code=( -drive "if=pflash,format=raw,readonly=on,file=${pkgs.OVMF.fd}/FV/AAVMF_CODE.fd" )
|
||||
pflash_vars=( -drive "if=pflash,format=raw,file=$varsTmp" )
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported arch: $arch" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
tmpFile=$(mktemp /tmp/test-image.XXXXXX)
|
||||
trap 'rm -f "$tmpFile"' EXIT
|
||||
cp "$img" "$tmpFile"
|
||||
|
||||
"$qemu_bin" \
|
||||
"''\${accel[@]}" \
|
||||
"''\${machine[@]}" \
|
||||
"''\${cpu[@]}" \
|
||||
"''\${ram[@]}" \
|
||||
"''\${smp[@]}" \
|
||||
-netdev user,id=net0,hostfwd=tcp::2222-:22 \
|
||||
-device virtio-net-pci,netdev=net0 \
|
||||
-drive if=pflash,format=raw,readonly=on,file=${OVMF.firmware} \
|
||||
-drive if=pflash,format=raw,readonly=on,file=${OVMF.variables} \
|
||||
"''\${pflash_code[@]}" \
|
||||
"''\${pflash_vars[@]}" \
|
||||
-drive "if=virtio,format=raw,file=$tmpFile"
|
||||
'';
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@ in
|
||||
# variant = "4";
|
||||
# };
|
||||
# kernelPackages = kernelBundle.linuxPackages_rpi4;
|
||||
kernelPackages = pkgs.${namespace}.linuxPackages_rpi4;
|
||||
kernelPackages = pkgs.linuxPackages_latest;
|
||||
supportedFilesystems = lib.mkForce [ ];
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user