rcore-os / rcore-os/rCore-Tutorial-v3

Nix flakes 支持

Open
#121 0 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
2.1k
Forks
560
PR merge metrics
No merged PRs in 30d

Description

目前基本完成了nix flakes的配置,可以在nix环境下直接通过nix develop打开执行环境,尽可能的降低课程依赖的安装对于外界环境的影响也可以更好的移除,可能具有更好的平台适用性,但是我没测试过

注意:使用本文的方法最好需要有一定nix的使用基础,以在可能出错的地方修改代码使之正常运行。(本文的代码尚未完全测试)

配置文件最新地址
如果在使用的过程中遇到了任何问题,欢迎回复(就是不一定我能解决

# update in 2023-05-24 21:26
{
  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
            libclang
            # 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
          '';
        };
      }
    );
}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked Nix flake configuration and run nix develop in the repository. Check how the configuration uses rust-toolchain.toml or rust-toolchain, cross-compiles for RISC-V, and provides QEMU. Done means the development environment works as documented and the configuration has been tested.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
build-system, developer-experience
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.