diff options
| author | andromeda <andromeda@lenovo> | 2026-03-03 22:01:49 +0100 |
|---|---|---|
| committer | andromeda <andromeda@lenovo> | 2026-03-03 22:01:49 +0100 |
| commit | 1b6f76488dcc01c8e6c0efbe07751ebeea18c33b (patch) | |
| tree | b1a0c6fb6c60a1716d41cb42670605f24d1f0f17 /nix/pkgs/bootler.nix | |
| parent | d879df630f68bb56f291ac285f951ca2ba6764e7 (diff) | |
add rust kernel stub
Diffstat (limited to 'nix/pkgs/bootler.nix')
| -rw-r--r-- | nix/pkgs/bootler.nix | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/nix/pkgs/bootler.nix b/nix/pkgs/bootler.nix new file mode 100644 index 0000000..3e5d2e4 --- /dev/null +++ b/nix/pkgs/bootler.nix @@ -0,0 +1,49 @@ +{ + stdenv, + nasm, + qemu, + ... +}: let + bootImg = "boot"; +in + stdenv.mkDerivation { + pname = "bootler"; + version = "0.1.0"; + src = ../../.; + buildPhase = '' + ${nasm}/bin/nasm asm/boot.asm -o boot.bin + ${nasm}/bin/nasm asm/kernel.asm -o dummy.bin + + dd if=/dev/zero of=${bootImg} bs=512 count=2 + dd if=boot.bin of=${bootImg} conv=notrunc + dd if=dummy.bin of=${bootImg} bs=512 seek=1 conv=notrunc + ''; + installPhase = '' + mkdir -p $out/bin + cp boot.bin $out/bin + cp dummy.bin $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} + + # run image + ${qemu}/bin/qemu-system-x86_64 \ + -nographic \ + -drive file=./.bootler/${bootImg},format=raw,index=0,media=disk + + # clean up + rm ./.bootler -r + + EOF + + chmod +x $out/bin/${bootImg} + chmod +x $out/bin/bootler + ''; + } |
