ysyx-workbench/nemu/default.nix

72 lines
974 B
Nix
Raw Normal View History

2024-08-15 10:36:23 +00:00
{ stdenv
, lib
, gnumake
, pkg-config
, bison
, flex
, dtc
, check
, mini-gdbstub
, readline
, libllvm
, SDL2
, am-kernels ? ""
, defconfig ? "alldefconfig"
}:
stdenv.mkDerivation rec {
pname = "nemu";
2024-08-15 10:36:23 +00:00
version = "2024-08-15";
src = ./.;
2024-08-15 10:36:23 +00:00
nativeBuildInputs = [
gnumake
2024-03-06 04:50:56 +00:00
pkg-config
flex
bison
2024-03-25 17:53:17 +00:00
dtc
];
2024-08-15 10:36:23 +00:00
buildInputs = [
SDL2
readline
libllvm
2024-04-25 08:54:27 +00:00
mini-gdbstub
];
2024-03-06 04:50:56 +00:00
checkInputs = [
2024-08-15 10:36:23 +00:00
check
2024-03-06 04:50:56 +00:00
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
'';
2024-08-15 10:36:23 +00:00
doCheck = (am-kernels != "");
checkPhase = ''
export NEMU_IMAGES_PATH=${am-kernels}/share/am-kernels
make test
2024-08-15 10:36:23 +00:00
'';
installPhase = ''
2024-08-15 10:36:23 +00:00
if [ -d "./lib" ] && [ "$(ls -A ./lib)" ]; then
mkdir -p "$out/lib"
fi
if [ -d "./bin" ] && [ "$(ls -A ./bin)" ]; then
mkdir -p $out/bin
fi
make PREFIX=$out install
'';
2024-03-06 04:50:56 +00:00
shellHook = ''
export NEMU_HOME=$(pwd)
'';
}