refactor: move cross compile to seperate flake attribute
This commit is contained in:
parent
422ff9e006
commit
ef51673020
2 changed files with 25 additions and 37 deletions
|
@ -128,11 +128,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1714032877,
|
"lastModified": 1721457008,
|
||||||
"narHash": "sha256-6KKe4xdHPQbGtM5icLHKxgcYyFKF47a98csTQG7vkvU=",
|
"narHash": "sha256-ekpve0om5hzC1Ntd3zm1cZ9oS5pnr7a2n/tueyqFOsg=",
|
||||||
"ref": "refs/heads/master",
|
"ref": "refs/heads/master",
|
||||||
"rev": "f6acae14927a6df78ce2304007369095e140da9c",
|
"rev": "e7aa3319d52fa987ac2192f63aef3dcb1b057e3a",
|
||||||
"revCount": 149,
|
"revCount": 151,
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://git.xinyang.life/xin/nur.git"
|
"url": "https://git.xinyang.life/xin/nur.git"
|
||||||
},
|
},
|
||||||
|
|
54
flake.nix
54
flake.nix
|
@ -13,7 +13,7 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = { self, ... }@inputs: with inputs;
|
outputs = { self, flake-utils, nixpkgs, nixpkgs-circt162, pre-commit-hooks, nur-xin }@inputs:
|
||||||
flake-utils.lib.eachDefaultSystem (system:
|
flake-utils.lib.eachDefaultSystem (system:
|
||||||
let
|
let
|
||||||
pkgs = import nixpkgs {
|
pkgs = import nixpkgs {
|
||||||
|
@ -26,7 +26,8 @@
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
crossPkgs = import nixpkgs {
|
|
||||||
|
rv32CrossConfig = import nixpkgs {
|
||||||
localSystem = system;
|
localSystem = system;
|
||||||
crossSystem = {
|
crossSystem = {
|
||||||
config = "riscv32-none-elf";
|
config = "riscv32-none-elf";
|
||||||
|
@ -53,33 +54,17 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
packages.nemu = pkgs.callPackage ./nemu { am-kernels = self.packages.${system}.am-kernels; };
|
packages = rec {
|
||||||
packages.nemu-lib = pkgs.callPackage ./nemu { am-kernels = self.packages.${system}.am-kernels; defconfig = "riscv32-lib_defconfig"; };
|
abstract-machine = pkgs.callPackage ./abstract-machine { isa = "native"; };
|
||||||
packages.abstract-machine = crossPkgs.callPackage ./abstract-machine { isa = "riscv"; platform = [ "nemu" "npc" ]; };
|
nemu = pkgs.callPackage ./nemu { };
|
||||||
packages.abstract-machine-native = pkgs.callPackage ./abstract-machine { isa = "native"; };
|
nemu-lib = pkgs.callPackage ./nemu { };
|
||||||
|
am-kernels = pkgs.callPackage ./am-kernels { abstract-machine = abstract-machine; arch = "native"; };
|
||||||
|
|
||||||
packages.am-kernels = crossPkgs.stdenv.mkDerivation rec {
|
rv32Cross = rec {
|
||||||
pname = "am-kernels-cmake";
|
abstract-machine = rv32CrossConfig.callPackage ./abstract-machine { isa = "riscv"; platform = [ "nemu" "npc" ]; };
|
||||||
version = "2024.02.18";
|
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"; };
|
||||||
src = ./am-kernels;
|
};
|
||||||
|
|
||||||
nativeBuildInputs = [
|
|
||||||
pkgs.cmake
|
|
||||||
pkgs.gcc # Generate expr tests
|
|
||||||
];
|
|
||||||
|
|
||||||
cmakeFlags = [
|
|
||||||
(pkgs.lib.cmakeFeature "ARCH" "riscv-nemu")
|
|
||||||
];
|
|
||||||
|
|
||||||
buildInputs = [
|
|
||||||
# SDL2
|
|
||||||
self.packages.${system}.abstract-machine
|
|
||||||
];
|
|
||||||
|
|
||||||
cmakeBuildType = "RelWithDebInfo";
|
|
||||||
dontStrip = true;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
devShells.nemu = pkgs.mkShell {
|
devShells.nemu = pkgs.mkShell {
|
||||||
|
@ -101,13 +86,14 @@
|
||||||
self.packages.${system}.nemu
|
self.packages.${system}.nemu
|
||||||
];
|
];
|
||||||
NEMU_HOME = "/home/xin/repo/ysyx-workbench/nemu";
|
NEMU_HOME = "/home/xin/repo/ysyx-workbench/nemu";
|
||||||
NEMU_IMAGES_PATH = self.packages.${system}.am-kernels + "/share/am-kernels";
|
NEMU_IMAGES_PATH = self.packages.${system}.rv32Cross.am-kernels-nemu + "/share/am-kernels";
|
||||||
};
|
};
|
||||||
|
|
||||||
devShells.npc = with pkgs; mkShell.override { stdenv = ccacheStdenv; } {
|
devShells.npc = pkgs.mkShell.override { stdenv = pkgs.ccacheStdenv; } {
|
||||||
inherit (self.checks.${system}.pre-commit-check) shellHook;
|
inherit (self.checks.${system}.pre-commit-check) shellHook;
|
||||||
CHISEL_FIRTOOL_PATH = "${nixpkgs-circt162.legacyPackages.${system}.circt}/bin";
|
CHISEL_FIRTOOL_PATH = "${nixpkgs-circt162.legacyPackages.${system}.circt}/bin";
|
||||||
packages = [
|
NPC_IMAGES_DIR="${self.packages.${system}.am-kernels-npc}/share/am-kernels";
|
||||||
|
packages = with pkgs; [
|
||||||
clang-tools
|
clang-tools
|
||||||
cmake
|
cmake
|
||||||
coursier
|
coursier
|
||||||
|
@ -120,7 +106,7 @@
|
||||||
gtkwave
|
gtkwave
|
||||||
];
|
];
|
||||||
|
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs = with pkgs; [
|
||||||
cmake
|
cmake
|
||||||
sbt
|
sbt
|
||||||
nvboard
|
nvboard
|
||||||
|
@ -130,14 +116,16 @@
|
||||||
flex
|
flex
|
||||||
bison
|
bison
|
||||||
verilator
|
verilator
|
||||||
|
self.packages.${system}.am-kernels-npc
|
||||||
];
|
];
|
||||||
|
|
||||||
buildInputs = [
|
buildInputs = with pkgs; [
|
||||||
nvboard
|
nvboard
|
||||||
openssl
|
openssl
|
||||||
libllvm
|
libllvm
|
||||||
libxml2
|
libxml2
|
||||||
readline
|
readline
|
||||||
|
mini-gdbstub
|
||||||
] ++ self.checks.${system}.pre-commit-check.enabledPackages;
|
] ++ self.checks.${system}.pre-commit-check.enabledPackages;
|
||||||
|
|
||||||
cmakeFlags = [
|
cmakeFlags = [
|
||||||
|
|
Loading…
Reference in a new issue