diff options
| author | andromeda <andromeda@lenovo> | 2026-03-06 16:53:18 +0100 |
|---|---|---|
| committer | andromeda <andromeda@lenovo> | 2026-03-06 16:53:18 +0100 |
| commit | d35463e1959cb64828c3166527b06e4a79cbea5e (patch) | |
| tree | 65017b84447f63eaaac8326c6d18f5c5e34e6bac /bootle/package.nix | |
| parent | fdf5bb9daf8574b7f993e2e38e400c35aedc3b96 (diff) | |
reorganise
Diffstat (limited to 'bootle/package.nix')
| -rw-r--r-- | bootle/package.nix | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/bootle/package.nix b/bootle/package.nix new file mode 100644 index 0000000..a5de5eb --- /dev/null +++ b/bootle/package.nix @@ -0,0 +1,68 @@ +{ + callPackage, + rust-bin, + naersk, + bootler, + qemu, + ... +}: let + rust-toolchain = rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; + naersk' = callPackage naersk { + cargo = rust-toolchain; + rustc = rust-toolchain; + clippy = rust-toolchain; + }; +in (naersk'.buildPackage { + src = ./.; + + # deps for rust-src + additionalCargoLock = "${rust-toolchain.availableComponents.rust-src}/lib/rustlib/src/rust/library/Cargo.lock"; + + # just library build + copyBins = false; + copyLibs = true; + release = true; + + # build std + cargoBuildOptions = x: + x + ++ [ + "-Zbuild-std" + ]; + + postInstall = '' + ld --oformat binary \ + -o kernel.bin \ + -T src/linker.ld \ + -e _start \ + target/x86_64-unknown-none/release/libbootle.a + + dd if=/dev/zero of=disk bs=512 count=2 + dd if=${bootler}/bin/boot.bin of=disk conv=notrunc + dd if=kernel.bin of=disk bs=512 seek=1 conv=notrunc + + mkdir -p $out/lib + mkdir -p $out/bin + + cat<<EOF>$out/bin/bootle + #!/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/bootle + + cp target/x86_64-unknown-none/release/libbootle.a $out/lib + cp kernel.bin $out/bin + cp disk $out/bin + ''; +}) |
