2024-03-04 03:59:50 +00:00
|
|
|
{
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
2024-04-05 02:23:28 +00:00
|
|
|
nixpkgs-circt162.url = "github:NixOS/nixpkgs/7995cae3ad60e3d6931283d650d7f43d31aaa5c7";
|
2024-03-04 03:59:50 +00:00
|
|
|
flake-utils.url = "github:numtide/flake-utils";
|
2024-04-05 02:23:28 +00:00
|
|
|
pre-commit-hooks = {
|
|
|
|
url = "github:cachix/pre-commit-hooks.nix";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
|
|
|
nur-xin = {
|
|
|
|
url = "git+https://git.xinyang.life/xin/nur.git";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
2024-03-04 03:59:50 +00:00
|
|
|
};
|
|
|
|
|
2024-07-23 09:16:40 +00:00
|
|
|
outputs = { self, flake-utils, nixpkgs, nixpkgs-circt162, pre-commit-hooks, nur-xin }@inputs:
|
2024-03-04 03:59:50 +00:00
|
|
|
flake-utils.lib.eachDefaultSystem (system:
|
|
|
|
let
|
2024-04-05 02:23:28 +00:00
|
|
|
pkgs = import nixpkgs {
|
|
|
|
inherit system;
|
|
|
|
config.allowUnfree = true;
|
|
|
|
overlays = [
|
|
|
|
(self: super: {
|
|
|
|
nvboard = nur-xin.legacyPackages.${system}.nvboard;
|
2024-07-09 12:43:47 +00:00
|
|
|
mini-gdbstub = nur-xin.legacyPackages.${system}.mini-gdbstub;
|
2024-04-05 02:23:28 +00:00
|
|
|
})
|
|
|
|
];
|
|
|
|
};
|
2024-07-23 09:16:40 +00:00
|
|
|
|
|
|
|
rv32CrossConfig = import nixpkgs {
|
2024-03-04 03:59:50 +00:00
|
|
|
localSystem = system;
|
|
|
|
crossSystem = {
|
|
|
|
config = "riscv32-none-elf";
|
2024-03-25 09:29:46 +00:00
|
|
|
gcc = {
|
|
|
|
abi = "ilp32";
|
|
|
|
arch = "rv32if";
|
|
|
|
};
|
2024-03-04 03:59:50 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
in
|
|
|
|
{
|
2024-04-05 02:23:28 +00:00
|
|
|
checks = {
|
|
|
|
pre-commit-check = pre-commit-hooks.lib.${system}.run {
|
|
|
|
src = ./.;
|
|
|
|
hooks = {
|
|
|
|
trim-trailing-whitespace.enable = true;
|
2024-04-13 13:15:56 +00:00
|
|
|
end-of-file-fixer.enable = true;
|
|
|
|
cmake-format.enable = true;
|
2024-04-05 02:23:28 +00:00
|
|
|
clang-format = {
|
|
|
|
enable = true;
|
|
|
|
types_or = pkgs.lib.mkForce [ "c" "c++" ];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2024-04-05 03:30:52 +00:00
|
|
|
|
2024-07-23 09:16:40 +00:00
|
|
|
packages = rec {
|
|
|
|
abstract-machine = pkgs.callPackage ./abstract-machine { isa = "native"; };
|
|
|
|
nemu = pkgs.callPackage ./nemu { };
|
|
|
|
nemu-lib = pkgs.callPackage ./nemu { };
|
|
|
|
am-kernels = pkgs.callPackage ./am-kernels { abstract-machine = abstract-machine; arch = "native"; };
|
2024-03-04 03:59:50 +00:00
|
|
|
|
2024-07-23 09:16:40 +00:00
|
|
|
rv32Cross = rec {
|
|
|
|
abstract-machine = rv32CrossConfig.callPackage ./abstract-machine { isa = "riscv"; platform = [ "nemu" "npc" ]; };
|
|
|
|
am-kernels-npc = rv32CrossConfig.callPackage ./am-kernels { inherit abstract-machine; arch = "riscv-npc"; };
|
|
|
|
am-kernels-nemu = rv32CrossConfig.callPackage ./am-kernels { inherit abstract-machine; arch = "riscv-nemu"; };
|
|
|
|
};
|
2024-03-04 03:59:50 +00:00
|
|
|
};
|
2024-04-05 02:23:28 +00:00
|
|
|
|
2024-03-07 05:19:12 +00:00
|
|
|
devShells.nemu = pkgs.mkShell {
|
|
|
|
packages = with pkgs; [
|
|
|
|
clang-tools
|
2024-03-20 11:46:54 +00:00
|
|
|
gdb
|
2024-07-09 12:43:47 +00:00
|
|
|
SDL2
|
|
|
|
gnumake
|
|
|
|
pkg-config
|
|
|
|
flex
|
|
|
|
bison
|
|
|
|
dtc
|
|
|
|
|
|
|
|
readline
|
|
|
|
libllvm
|
|
|
|
mini-gdbstub
|
2024-03-07 05:19:12 +00:00
|
|
|
];
|
|
|
|
inputsFrom = [
|
|
|
|
self.packages.${system}.nemu
|
|
|
|
];
|
2024-07-09 09:06:15 +00:00
|
|
|
NEMU_HOME = "/home/xin/repo/ysyx-workbench/nemu";
|
2024-07-23 09:16:40 +00:00
|
|
|
NEMU_IMAGES_PATH = self.packages.${system}.rv32Cross.am-kernels-nemu + "/share/am-kernels";
|
2024-03-07 05:19:12 +00:00
|
|
|
};
|
2024-04-05 02:23:28 +00:00
|
|
|
|
2024-07-23 09:16:40 +00:00
|
|
|
devShells.npc = pkgs.mkShell.override { stdenv = pkgs.ccacheStdenv; } {
|
2024-04-05 02:23:28 +00:00
|
|
|
inherit (self.checks.${system}.pre-commit-check) shellHook;
|
|
|
|
CHISEL_FIRTOOL_PATH = "${nixpkgs-circt162.legacyPackages.${system}.circt}/bin";
|
2024-07-23 09:16:40 +00:00
|
|
|
NPC_IMAGES_DIR="${self.packages.${system}.am-kernels-npc}/share/am-kernels";
|
|
|
|
packages = with pkgs; [
|
2024-04-05 02:23:28 +00:00
|
|
|
clang-tools
|
|
|
|
cmake
|
|
|
|
coursier
|
|
|
|
espresso
|
|
|
|
bloop
|
|
|
|
|
|
|
|
gdb
|
|
|
|
jre
|
|
|
|
|
|
|
|
gtkwave
|
|
|
|
];
|
|
|
|
|
2024-07-23 09:16:40 +00:00
|
|
|
nativeBuildInputs = with pkgs; [
|
2024-04-05 02:23:28 +00:00
|
|
|
cmake
|
|
|
|
sbt
|
|
|
|
nvboard
|
|
|
|
nixpkgs-circt162.legacyPackages.${system}.circt
|
|
|
|
yosys
|
|
|
|
cli11
|
2024-04-09 09:03:21 +00:00
|
|
|
flex
|
|
|
|
bison
|
|
|
|
verilator
|
2024-07-23 09:16:40 +00:00
|
|
|
self.packages.${system}.am-kernels-npc
|
2024-04-05 02:23:28 +00:00
|
|
|
];
|
|
|
|
|
2024-07-23 09:16:40 +00:00
|
|
|
buildInputs = with pkgs; [
|
2024-04-05 02:23:28 +00:00
|
|
|
nvboard
|
2024-04-05 03:30:52 +00:00
|
|
|
openssl
|
2024-04-09 09:03:21 +00:00
|
|
|
libllvm
|
|
|
|
libxml2
|
|
|
|
readline
|
2024-07-23 09:16:40 +00:00
|
|
|
mini-gdbstub
|
2024-04-05 02:23:28 +00:00
|
|
|
] ++ self.checks.${system}.pre-commit-check.enabledPackages;
|
2024-04-05 03:30:52 +00:00
|
|
|
|
|
|
|
cmakeFlags = [
|
|
|
|
"-DDIFFTEST_LIB:string=${self.packages.${system}.nemu-lib}/lib/riscv32-nemu-interpreter-so"
|
|
|
|
];
|
2024-04-05 02:23:28 +00:00
|
|
|
};
|
2024-03-04 03:59:50 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|