{ inputs = { fenix-flake = { url = "github:nix-community/fenix"; inputs.nixpkgs.follows = "nixpkgs"; }; }; outputs = { self, fenix-flake, flake-utils, nixpkgs, }: flake-utils.lib.eachSystem [ "aarch64-linux" "x86_64-linux" ] ( system: let pkgs = nixpkgs.legacyPackages.${system}; fenix = fenix-flake.packages.${system}; arches = import ./arches.nix; python = pkgs.python3.withPackages (ps: [ ps.ninja ]); rust-toolchain = fenix.combine ( [ fenix.stable.cargo fenix.stable.rustc fenix.stable.clippy ] ++ (builtins.map ({ rust-target, ... }: fenix.targets.${rust-target}.stable.rust-std) ( builtins.attrValues arches )) ); packages = rec { kernel = import ./boards { inherit arches libkernel nixpkgs pkgs python system ; }; libkernel = import ./crates { inherit arches fenix nixpkgs system ; }; }; in /* pkgsHost = import nixpkgs { inherit system; crossSystem.config = "riscv64-unknown-none-elf"; }; packages = rec { boards = import ./boards { inherit libkernel; pkgs = pkgsHost; }; libkernel = pkgsBuild.callPackage ./kernel { inherit rust; }; }; run-vm = pkgsBuild.writeShellApplication { name = "run-vm"; runtimeInputs = [ pkgsBuild.qemu ]; text = '' set -x qemu-system-riscv64 \ -machine virt \ -m 1G \ -nographic \ -bios none \ -kernel ${packages.boards.qemu-virt}/kernel.elf \ "$@" ''; }; */ { /* apps = { default = { type = "app"; program = pkgsBuild.lib.getExe run-vm; }; run = { type = "app"; program = pkgsBuild.lib.getExe run-vm; }; debug = { type = "app"; program = pkgsBuild.lib.getExe ( pkgsBuild.writeShellApplication { name = "run-vm-debug"; runtimeInputs = [ run-vm ]; text = '' port=$(( 1000 * ("$(id -u)" - 990) )) run-vm -gdb tcp::$port -S "$@" ''; } ); }; gdb = { type = "app"; program = pkgsBuild.lib.getExe ( pkgsBuild.writeShellApplication { name = "gdb"; runtimeInputs = [ toolchain ]; text = '' port=$(( 1000 * ("$(id -u)" - 990) )) rust-gdb ${packages.boards.qemu-virt}/kernel.elf \ -ex "target remote 127.0.0.1:$port" \ -ex "set riscv use-compressed-breakpoints yes" \ -ex "layout asm" \ -ex "layout regs" \ -ex "focus cmd" \ -ex "tbreak hart0_boot" \ -ex "c" ''; } ); }; }; */ devShells.default = pkgs.mkShell { nativeBuildInputs = [ (pkgs.callPackage ./nix/miri.nix { inherit fenix; }) pkgs.cargo-watch pkgs.qemu python rust-toolchain ]; }; packages = flake-utils.lib.flattenTree packages; } ); }