Last active
October 26, 2024 17:49
-
-
Save jackyliu16/e6952c26a3810e4b46a1d348831984dd to your computer and use it in GitHub Desktop.
A flake of nix for rCore
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
description = "A devShell for rCore"; | |
inputs = { | |
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; | |
nixpkgs-qemu7.url = "https://github.com/NixOS/nixpkgs/archive/7cf5ccf1cdb2ba5f08f0ac29fc3d04b0b59a07e4.tar.gz"; | |
rust-overlay.url = "github:oxalica/rust-overlay"; | |
flake-utils.url = "github:numtide/flake-utils"; | |
}; | |
outputs = { self, nixpkgs, nixpkgs-qemu7, rust-overlay, flake-utils, ... }: | |
flake-utils.lib.eachDefaultSystem (system: | |
let | |
overlays = [ | |
(import rust-overlay) | |
(self: super: { | |
# ref: https://github.com/the-nix-way/dev-templates | |
rust-toolchain = | |
let | |
rust = super.rust-bin; | |
in | |
if builtins.pathExists ./rust-toolchain.toml then | |
rust.fromRustupToolchainFile ./rust-toolchain.toml | |
else if builtins.pathExists ./rust-toolchain then | |
rust.fromRustupToolchainFile ./rust-toolchain | |
else | |
# The rust-toolchain when i make this file, which maybe change | |
(rust.nightly."2022-08-05".minimal.override { | |
extensions = [ "rust-src" "llvm-tools-preview" "rustfmt" "clippy" ]; | |
targets = [ "riscv64gc-unknown-none-elf" ]; | |
}); | |
qemu = self.callPackage "${nixpkgs-qemu7}/pkgs/applications/virtualization/qemu" { | |
inherit (self.darwin.apple_sdk.frameworks) CoreServices Cocoa Hypervisor; | |
inherit (self.darwin.stubs) rez setfile; | |
inherit (self.darwin) sigtool; | |
# Reduces the number of qemu source files from ~10000 to ~2600 source files. | |
hostCpuTargets = ["riscv64-softmmu" "riscv32-softmmu"]; | |
}; | |
}) | |
]; | |
pkgs = import nixpkgs { | |
inherit system overlays; | |
}; | |
in | |
{ | |
devShells.default = pkgs.mkShell { | |
buildInputs = (with pkgs;[ | |
# Basic | |
openssl | |
pkg-config | |
exa | |
fd | |
qemu | |
# Cross Compile | |
(with pkgsCross.riscv64; [ musl.stdenv.cc ]) # If use normally, no necessary need to change. | |
# Rust Configuraiton | |
rustup | |
cargo-binutils | |
rust-toolchain | |
]); | |
shellHook = '' | |
alias ls=exa | |
alias find=fd | |
''; | |
}; | |
} | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@gjz010 would you be interested in another one?
Another rust operating system support Multiple Architectur, which flake haven't complete yet.