blob: 150b46bb0db67732cd0474b01e43816e3ddb6e97 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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
'';
}
|