forked from arceos-org/arceos-staging
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
131 lines (121 loc) · 5.26 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
{
description = "Only Provide the support of qemu";
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
rust.nightly.latest.default;
# The rust-toolchain when i make this file, which maybe change
# (rust.nightly.latest.override {
# extensions = [ "rust-src" "llvm-tools-preview" "rustfmt" "clippy" ];
# targets = [ "x86_64-unknown-none" "riscv64gc-unknown-none-elf" "aarch64-unknown-none-softfloat" ];
# });
qemu7 = 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 ~3619 source files.
hostCpuTargets = ["riscv64-softmmu" "riscv32-softmmu" "x86_64-softmmu" "aarch64-softmmu" ];
};
x86_64-linux-musl-cross = fetchTarball {
url = "https://musl.cc/x86_64-linux-musl-cross.tgz";
sha256 = "172zrq1y4pbb2rpcw3swkvmi95bsqq1z6hfqvkyd9wrzv6rwm9jw";
};
aarch64-linux-musl-cross = fetchTarball {
url = "https://musl.cc/aarch64-linux-musl-cross.tgz";
sha256 = "05cwryhr88sjmwykha5xvfy4vcrvwaz92r9an7n5bsyzlwwk0wpn";
};
riscv64-linux-musl-cross = fetchTarball {
url = "https://musl.cc/riscv64-linux-musl-cross.tgz";
sha256 = "119y1y3jwpa52jym3mxr9c2by5wjb4pr6afzvkq7s0dp75m5lzvb";
};
})
];
pkgs = import nixpkgs {
inherit system overlays;
};
in
{
devShells = {
# qemu = pkgs.mkShell {
# buildInputs = with pkgs; [
# vim
# # exa
# fd
# zlib
# qemu
# ];
# shellHook = ''
# alias ls=exa
# alias find=fd
# # Change the mirror of rust
# export RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-static
# export RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup
# unset OBJCOPY # Avoiding Overlay
# export LIBCLANG_PATH="${pkgs.llvmPackages.libclang.lib}/lib" # nixpkgs@52447
# export LD_LIBRARY_PATH="${pkgs.zlib}/lib:$LD_LIBRARY_PATH" # nixpkgs@92946
#
# export PATH=$PATH:$(realpath .)/.toolchain/aarch64-linux-musl-cross/bin:$(realpath .)/.toolchain/riscv64-linux-musl-cross/bin:$(realpath .)/.toolchain/x86_64-linux-musl-cross/bin/
# '';
# };
default = pkgs.mkShell {
buildInputs = (with pkgs;[
gnumake
# Basic
openssl
pkg-config
fd
# Development tools
ripgrep
fzf
zellij
# Rust Configuraiton
zlib
rustup
cargo-binutils
rust-toolchain
]) ++ [
# Overlays part
pkgs.qemu
];
# nativeBuildInputs = with pkgs; [
# llvmPackages.libclang
# llvmPackages.libcxxClang
# clang
# ];
# LIBCLANG_PATH="${pkgs.llvmPackages.libclang.lib}/lib"; # nixpkgs@52447
# BINDGEN_EXTRA_CLANG_ARGS = "-isystem ${pkgs.llvmPackages.libclang.lib}/lib/clang/${pkgs.lib.getVersion pkgs.clang}/include"; # https://github.com/NixOS/nixpkgs/issues/52447#issuecomment-853429315
shellHook = ''
alias find=fd
export SHELL=zsh
# Change the mirror of rust
export RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-static
export RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup
unset OBJCOPY # Avoiding Overlay
export LIBCLANG_PATH="${pkgs.llvmPackages.libclang.lib}/lib" # nixpkgs@52447
export LD_LIBRARY_PATH="${pkgs.zlib}/lib:$LD_LIBRARY_PATH" # nixpkgs@92946
export PATH=$PATH:${pkgs.aarch64-linux-musl-cross}/bin:${pkgs.riscv64-linux-musl-cross}/bin:${pkgs.x86_64-linux-musl-cross}/bin
'';
};
};
}
);
}