summaryrefslogtreecommitdiff
path: root/twasm/package.nix
diff options
context:
space:
mode:
authorandromeda <andromeda@lenovo>2026-03-06 20:33:51 +0100
committerandromeda <andromeda@lenovo>2026-03-06 20:33:51 +0100
commit9c65697dd8119ec9cee13f57f870b07e305d27ec (patch)
tree27b61bd7a27df6e25db8b21dc0ee3daed01d79fb /twasm/package.nix
parentfdf5bb9daf8574b7f993e2e38e400c35aedc3b96 (diff)
bunch of stuff idek
Diffstat (limited to 'twasm/package.nix')
-rw-r--r--twasm/package.nix41
1 files changed, 41 insertions, 0 deletions
diff --git a/twasm/package.nix b/twasm/package.nix
new file mode 100644
index 0000000..f621780
--- /dev/null
+++ b/twasm/package.nix
@@ -0,0 +1,41 @@
+{
+ bootler,
+ stdenv,
+ nasm,
+ qemu,
+ ...
+}:
+stdenv.mkDerivation {
+ pname = "twasm";
+ version = "0.1.0";
+ src = ./.;
+ buildPhase = ''
+ ${nasm}/bin/nasm asm/main.asm -o out.bin
+ '';
+ installPhase = ''
+ dd if=/dev/zero of=disk bs=512 count=2880
+ dd if=${bootler}/bin/boot.bin of=disk conv=notrunc
+ dd if=out.bin of=disk bs=512 seek=1 conv=notrunc
+
+ mkdir -p $out/bin
+
+ cat<<EOF>$out/bin/twasm
+ #!/usr/bin/env bash
+
+ mkdir -p ./.bootle
+ cp $(echo $out)/bin/disk ./.bootle/disk
+ chmod a+w ./.bootle/disk
+
+ ${qemu}/bin/qemu-system-x86_64 \
+ -nographic \
+ -drive file=./.bootle/disk,format=raw,index=0,media=disk
+
+ rm ./.bootle -r
+ EOF
+
+ chmod +x $out/bin/twasm
+
+ cp out.bin $out/bin
+ cp disk $out/bin
+ '';
+}