ysyx-workbench/flake.nix

186 lines
5.3 KiB
Nix
Raw Permalink Normal View History

{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
nixpkgs-circt162.url = "github:NixOS/nixpkgs/7995cae3ad60e3d6931283d650d7f43d31aaa5c7";
flake-utils.url = "github:numtide/flake-utils";
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-08-15 03:56:34 +00:00
diffu.url = "git+https://git.xinyang.life/xin/diffu.git";
am-kernels.url = "git+https://git.xinyang.life/xin/am-kernels.git?ref=dev";
2024-09-03 03:29:22 +00:00
spike-diff.url = "git+https://git.xinyang.life/xin/spike-diff.git";
};
2024-09-03 03:29:22 +00:00
outputs =
{
self,
flake-utils,
nixpkgs,
nixpkgs-circt162,
pre-commit-hooks,
nur-xin,
diffu,
am-kernels,
spike-diff,
}@inputs:
flake-utils.lib.eachDefaultSystem (
system:
let
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;
})
];
};
rv32CrossConfig = import nixpkgs {
localSystem = system;
crossSystem = {
config = "riscv32-none-elf";
2024-03-25 09:29:46 +00:00
gcc = {
abi = "ilp32";
arch = "rv32if";
};
};
};
2024-09-03 03:29:22 +00:00
am-kernels-nemu = am-kernels.packages.${system}.rv32Cross.am-kernels-nemu;
in
{
checks = {
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
trim-trailing-whitespace.enable = true;
end-of-file-fixer.enable = true;
cmake-format.enable = true;
clang-format = {
enable = true;
2024-09-03 03:29:22 +00:00
types_or = pkgs.lib.mkForce [
"c"
"c++"
];
};
2024-08-09 11:58:10 +00:00
scalafmt = {
enable = true;
package = pkgs.scalafmt;
name = "Scalafmt";
types = [ "scala" ];
entry = "${pkgs.scalafmt}/bin/scalafmt --non-interactive";
};
};
};
};
2024-04-05 03:30:52 +00:00
2024-09-03 03:29:22 +00:00
packages = {
abstract-machine = pkgs.callPackage ./abstract-machine { isa = "native"; };
2024-09-03 03:29:22 +00:00
nemu = pkgs.callPackage ./nemu { am-kernels = am-kernels-nemu; };
nemu-lib = pkgs.callPackage ./nemu { defconfig = "libdefconfig"; };
2024-09-03 03:29:22 +00:00
rv32Cross = {
abstract-machine = rv32CrossConfig.callPackage ./abstract-machine {
isa = "riscv";
platform = [
"nemu"
"npc"
];
};
};
};
devShells.nemu = pkgs.mkShell {
packages = with pkgs; [
clang-tools
gef
2024-07-09 12:43:47 +00:00
SDL2
gnumake
pkg-config
flex
bison
dtc
readline
libllvm
mini-gdbstub
];
inputsFrom = [
self.packages.${system}.nemu
];
NEMU_HOME = "/home/xin/repo/ysyx-workbench/nemu";
2024-09-03 03:29:22 +00:00
NEMU_IMAGES_PATH = am-kernels.packages.${system}.rv32Cross.am-kernels-nemu + "/share/am-kernels";
};
devShells.npc = pkgs.mkShell.override { stdenv = pkgs.ccacheStdenv; } {
inherit (self.checks.${system}.pre-commit-check) shellHook;
CHISEL_FIRTOOL_PATH = "${nixpkgs-circt162.legacyPackages.${system}.circt}/bin";
2024-08-13 12:11:38 +00:00
# NPC_IMAGES_PATH = "${self.packages.${system}.rv32Cross.am-kernels-npc}/share/am-kernels";
packages = with pkgs; [
clang-tools
cmake
coursier
espresso
bloop
gdb
jre
gtkwave
];
nativeBuildInputs = with pkgs; [
cmake
ninja
sbt
nvboard
nixpkgs-circt162.legacyPackages.${system}.circt
yosys
cli11
2024-04-09 09:03:21 +00:00
flex
bison
verilator
];
2024-09-03 03:29:22 +00:00
buildInputs =
with pkgs;
[
spdlog
nvboard
openssl
libllvm
libxml2
readline
mini-gdbstub
]
++ self.checks.${system}.pre-commit-check.enabledPackages;
};
2024-08-15 03:56:34 +00:00
2024-09-06 06:56:10 +00:00
devShells.default = pkgs.mkShell {
inherit (self.checks.${system}.pre-commit-check) shellHook;
buildInputs = self.checks.${system}.pre-commit-check.enabledPackages;
2024-08-15 03:56:34 +00:00
packages = [
diffu.packages.${system}.default
am-kernels.packages.${system}.rv32Cross.am-kernels-npc
self.packages.${system}.nemu-lib
2024-09-03 03:29:22 +00:00
spike-diff.packages.${system}.default
2024-09-06 06:56:10 +00:00
pkgs.gef
pkgs.gtkwave
2024-08-15 03:56:34 +00:00
];
2024-09-03 03:29:22 +00:00
2024-09-06 06:56:10 +00:00
DIFFU_IMAGES_PATH = "${am-kernels.packages.${system}.rv32Cross.am-kernels-npc}";
NEMU_SO = "${self.packages.${system}.nemu-lib}/lib/riscv32-nemu-interpreter-so";
NPC_SO = "/home/xin/repo/ysyx-workbench/npc/build/csrc/Flow/libFlow.so";
2024-08-15 03:56:34 +00:00
};
}
);
}