init
This commit is contained in:
75
package.nix
Normal file
75
package.nix
Normal file
@@ -0,0 +1,75 @@
|
||||
{
|
||||
callPackage,
|
||||
grub2,
|
||||
naersk,
|
||||
nasm,
|
||||
qemu,
|
||||
rust-bin,
|
||||
xorriso,
|
||||
...
|
||||
}: let
|
||||
nightly = rust-bin.nightly.latest.default.override {
|
||||
extensions = ["rust-src"];
|
||||
};
|
||||
naersk' = callPackage naersk {
|
||||
cargo = nightly;
|
||||
rustc = nightly;
|
||||
};
|
||||
target = builtins.readFile ./x86_64-oxidos.json;
|
||||
in
|
||||
naersk'.buildPackage {
|
||||
name = "oxidos";
|
||||
src = ./.;
|
||||
|
||||
copyBins = false;
|
||||
release = true;
|
||||
|
||||
cargoBuildOptions = x: x ++ ["-Z" "build-std=core,compiler_builtins,alloc" "-Z" "build-std-features=compiler-builtins-mem" "--target=x86_64-oxidos.json"];
|
||||
|
||||
buildInputs = [
|
||||
qemu
|
||||
];
|
||||
nativeBuildInputs = [
|
||||
grub2
|
||||
nasm
|
||||
xorriso
|
||||
];
|
||||
|
||||
preBuild = ''
|
||||
cat << EOF > x86_64-oxidos.json
|
||||
${target}
|
||||
EOF
|
||||
'';
|
||||
postInstall = ''
|
||||
nasm -f elf64 asm/multiboot_header.asm -o multiboot_header.asm.o
|
||||
nasm -f elf64 asm/long_mode_init.asm -o long_mode_init.asm.o
|
||||
nasm -f elf64 asm/boot.asm -o boot.asm.o
|
||||
|
||||
ld -n -o kernel.bin\
|
||||
--gc-sections\
|
||||
-T link-cfg/linker.ld\
|
||||
multiboot_header.asm.o\
|
||||
long_mode_init.asm.o\
|
||||
boot.asm.o\
|
||||
target/x86_64-oxidos/release/liboxidos.a
|
||||
|
||||
mkdir isofiles/boot/grub -p
|
||||
cp kernel.bin isofiles/boot/kernel.bin
|
||||
cp link-cfg/grub.cfg isofiles/boot/grub/grub.cfg
|
||||
|
||||
grub-mkrescue -o os.iso isofiles
|
||||
|
||||
echo "#!/usr/bin/env bash" > oxidos
|
||||
echo "${qemu}/bin/qemu-system-x86_64 -cdrom $(echo $out)/os.iso" >> oxidos
|
||||
chmod +x oxidos
|
||||
|
||||
mkdir $out/bin -p
|
||||
cp oxidos $out/bin/oxidos
|
||||
cp os.iso $out/os.iso
|
||||
'';
|
||||
|
||||
meta = {
|
||||
mainProgram = "oxidos";
|
||||
homepage = "https://mtgmonkey.net";
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user