check
This commit is contained in:
@@ -24,6 +24,8 @@ in
|
|||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
boot = {
|
boot = {
|
||||||
|
|
||||||
|
kernelModules = [ "kvm" ];
|
||||||
|
|
||||||
binfmt = lib.mkIf isArm {
|
binfmt = lib.mkIf isArm {
|
||||||
registrations."x86_64-linux" = {
|
registrations."x86_64-linux" = {
|
||||||
magicOrExtension = ''\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x3e\x00'';
|
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);
|
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.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;
|
grub.enable = lib.mkForce false;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -42,9 +42,8 @@ if [ -n "$fwtarget" ]; then
|
|||||||
@firmwareBuilder@ -c $default -d $fwtarget
|
@firmwareBuilder@ -c $default -d $fwtarget
|
||||||
|
|
||||||
echo "copying uefi firmware..."
|
echo "copying uefi firmware..."
|
||||||
#for file in "@uefi@/*"; do
|
rm -rf $fwtarget/*
|
||||||
copyForced @uefi@ $fwtarget/
|
copyForced @uefi@ $fwtarget/
|
||||||
#done
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "uefi bootloader installed"
|
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";
|
name = "test-image";
|
||||||
runtimeInputs = [ qemu ];
|
runtimeInputs = [
|
||||||
|
pkgs.qemu
|
||||||
|
pkgs.OVMF
|
||||||
|
];
|
||||||
text = ''
|
text = ''
|
||||||
if [ -z "$1" ]; then
|
set -euo pipefail
|
||||||
echo "Usage: $0 <path-to-boot-image>"
|
|
||||||
|
if [ $# -lt 1 ]; then
|
||||||
|
echo "Usage: $0 <path-to-boot-image> [x86_64|aarch64]" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
tmpFile=$(mktemp /home/matt/tmp/test-image.XXXXXX)
|
|
||||||
trap 'rm -f $tmpFile' EXIT
|
img="$1"
|
||||||
cp "$1" "$tmpFile"
|
arch="''\${2:-$(uname -m)}"
|
||||||
qemu-system-x86_64 \
|
|
||||||
-enable-kvm \
|
accel=( -accel kvm )
|
||||||
-m 4G \
|
[ -e /dev/kvm ] || accel=( -accel "tcg,thread=multi" )
|
||||||
-cpu max \
|
|
||||||
-smp 4 \
|
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 \
|
-netdev user,id=net0,hostfwd=tcp::2222-:22 \
|
||||||
-device virtio-net-pci,netdev=net0 \
|
-device virtio-net-pci,netdev=net0 \
|
||||||
-drive if=pflash,format=raw,readonly=on,file=${OVMF.firmware} \
|
"''\${pflash_code[@]}" \
|
||||||
-drive if=pflash,format=raw,readonly=on,file=${OVMF.variables} \
|
"''\${pflash_vars[@]}" \
|
||||||
-drive "if=virtio,format=raw,file=$tmpFile"
|
-drive "if=virtio,format=raw,file=$tmpFile"
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
@@ -14,7 +14,7 @@ in
|
|||||||
# variant = "4";
|
# variant = "4";
|
||||||
# };
|
# };
|
||||||
# kernelPackages = kernelBundle.linuxPackages_rpi4;
|
# kernelPackages = kernelBundle.linuxPackages_rpi4;
|
||||||
kernelPackages = pkgs.${namespace}.linuxPackages_rpi4;
|
kernelPackages = pkgs.linuxPackages_latest;
|
||||||
supportedFilesystems = lib.mkForce [ ];
|
supportedFilesystems = lib.mkForce [ ];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user