diff options
Diffstat (limited to 'package.nix')
| -rw-r--r-- | package.nix | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/package.nix b/package.nix new file mode 100644 index 0000000..150b46b --- /dev/null +++ b/package.nix @@ -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 + ''; + } |
