Skip to content

Instantly share code, notes, and snippets.

@gjz010
Forked from jackyliu16/flake.nix
Created May 24, 2023 17:06
Show Gist options
  • Save gjz010/f5e7f0ea98fe39e0f64644db6b1a10d3 to your computer and use it in GitHub Desktop.
Save gjz010/f5e7f0ea98fe39e0f64644db6b1a10d3 to your computer and use it in GitHub Desktop.
A flake of nix for rCore
{
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, 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" ];
});
})
];
pkgs = import nixpkgs {
inherit system overlays;
};
# pkg-qemu = import nixpkgs-qemu7 { inherit system; };
in
{
devShells.default = pkgs.mkShell {
buildInputs = (with pkgs;[
# Basic
openssl
pkg-config
exa
fd
# Cross Compile
(with pkgsCross.riscv64; [ musl.stdenv.cc ]) # If use normally, no necessary need to change.
# Rust Configuraiton
rustup
cargo-binutils
rust-toolchain
]) ++ [
pkgs.qemu
# pkg-qemu.qemu
];
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