ysyx-workbench/nemu/default.nix

67 lines
1.1 KiB
Nix
Raw Normal View History

{ pkgs,
lib,
2024-03-06 04:50:56 +00:00
stdenv,
2024-04-05 03:30:52 +00:00
dtc,
2024-04-25 08:54:27 +00:00
mini-gdbstub,
am-kernels ? null,
2024-04-05 03:30:52 +00:00
defconfig ? "alldefconfig",
}:
stdenv.mkDerivation rec {
pname = "nemu";
version = "2024-03-02";
src = ./.;
nativeBuildInputs = with pkgs; [
gnumake
2024-03-06 04:50:56 +00:00
pkg-config
flex
bison
2024-03-25 17:53:17 +00:00
dtc
];
buildInputs = with pkgs; [
readline
libllvm
2024-04-25 08:54:27 +00:00
mini-gdbstub
];
2024-03-06 04:50:56 +00:00
checkInputs = [
pkgs.check
am-kernels
];
configurePhase = ''
2024-03-06 04:50:56 +00:00
export NEMU_HOME=$(pwd)
2024-04-05 03:30:52 +00:00
make ${defconfig}
'';
buildPhase = ''
make
'';
doCheck = (am-kernels != null);
2024-04-05 03:30:52 +00:00
checkPhase = if doCheck then ''
export NEMU_IMAGES_PATH=${am-kernels}/share/am-kernels
make test
2024-04-05 03:30:52 +00:00
'' else "";
installPhase = ''
mkdir -p $out/bin
2024-04-05 03:30:52 +00:00
mkdir -p $out/lib
make PREFIX=$out install
'';
2024-03-06 04:50:56 +00:00
shellHook = ''
export NEMU_HOME=$(pwd)
'';
meta = with lib; {
description = "NJU EMUlator, a full system x86/mips32/riscv32/riscv64 emulator for teaching";
homepage = "https://github.com/NJU-ProjectN/nemu.git";
license = with licenses; [ ];
maintainers = with maintainers; [ ];
};
}