boots in qemu

This commit is contained in:
andromeda
2026-02-28 23:25:10 +01:00
parent 1bd2067333
commit e98380107b
4 changed files with 61 additions and 1 deletions

45
package.nix Normal file
View File

@@ -0,0 +1,45 @@
{
stdenv,
nasm,
qemu,
...
}: let
bootImg = "boot";
in
stdenv.mkDerivation {
pname = "bootler";
version = "0.1.0";
src = ./.;
buildPhase = ''
${nasm}/bin/nasm boot.asm -o ${bootImg}
'';
installPhase = ''
mkdir -p $out/bin
cp ${bootImg} $out/bin
# create emulation binary
cat<<EOF>$out/bin/bootler
#!/usr/bin/env bash
# create temp dir
mkdir -p ./.bootler
cp $(echo $out)/bin/${bootImg} ./.bootler/${bootImg}
chmod a+w ./.bootler/${bootImg}
echo "press any key to continue. Qemu will clear the screen..."
read -s -n 1
# run image
${qemu}/bin/qemu-system-x86_64 \
-nographic \
-hda ./.bootler/${bootImg}
# clean up
rm ./.bootler -r
EOF
chmod +x $out/bin/${bootImg}
chmod +x $out/bin/bootler
'';
}