build: initial support for building nemu, am-kernels with nix
This commit is contained in:
parent
f9808d0a40
commit
3c7c5f060e
6 changed files with 139 additions and 123 deletions
49
nemu/default.nix
Normal file
49
nemu/default.nix
Normal file
|
@ -0,0 +1,49 @@
|
|||
{ pkgs,
|
||||
lib,
|
||||
stdenv
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "nemu";
|
||||
version = "2024-03-02";
|
||||
|
||||
src = ./.;
|
||||
|
||||
NEMU_HOME = "/build/nemu";
|
||||
nativeBuildInputs = with pkgs; [
|
||||
gnumake
|
||||
flex
|
||||
bison
|
||||
];
|
||||
|
||||
buildInputs = with pkgs; [
|
||||
check
|
||||
readline
|
||||
libllvm
|
||||
];
|
||||
|
||||
configurePhase = ''
|
||||
echo pwd=$(pwd)
|
||||
make alldefconfig
|
||||
'';
|
||||
|
||||
buildPhase = ''
|
||||
make
|
||||
'';
|
||||
|
||||
checkPhase = ''
|
||||
make test
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
make PREFIX=$out install
|
||||
'';
|
||||
|
||||
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; [ ];
|
||||
};
|
||||
}
|
82
nemu/flake.lock
generated
82
nemu/flake.lock
generated
|
@ -1,82 +0,0 @@
|
|||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1701680307,
|
||||
"narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "4022d587cbbfd70fe950c1e2083a02621806a725",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1704722960,
|
||||
"narHash": "sha256-mKGJ3sPsT6//s+Knglai5YflJUF2DGj7Ai6Ynopz0kI=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "317484b1ead87b9c1b8ac5261a8d2dd748a0492d",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nur-xin": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1704680562,
|
||||
"narHash": "sha256-ffec3HL8OgbHB/TvLHILvC3ylou6N+KDtrn4qYVV+U4=",
|
||||
"ref": "refs/heads/master",
|
||||
"rev": "8adf33b6fdd113c645d83feda28622a0b1ef9f83",
|
||||
"revCount": 144,
|
||||
"type": "git",
|
||||
"url": "https://git.xinyang.life/xin/nur.git"
|
||||
},
|
||||
"original": {
|
||||
"type": "git",
|
||||
"url": "https://git.xinyang.life/xin/nur.git"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"nur-xin": "nur-xin"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
|
@ -1,80 +0,0 @@
|
|||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
nur-xin = {
|
||||
url = "git+https://git.xinyang.life/xin/nur.git";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
};
|
||||
|
||||
outputs = { self, ... }@inputs: with inputs;
|
||||
flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system} //
|
||||
{ nur.xin = nur-xin.legacyPackages.${system}; };
|
||||
in
|
||||
{
|
||||
devShells.default = with pkgs; mkShell {
|
||||
packages = [
|
||||
clang-tools
|
||||
rnix-lsp
|
||||
bear
|
||||
|
||||
gdb
|
||||
jre
|
||||
|
||||
gtkwave
|
||||
];
|
||||
|
||||
inputsFrom = [ self.packages.${system}.nemu ];
|
||||
};
|
||||
|
||||
packages.nemu = with pkgs; stdenv.mkDerivation rec {
|
||||
pname = "nemu";
|
||||
version = "2024-01-02";
|
||||
|
||||
src = ./.;
|
||||
|
||||
nativeBuildInputs = [
|
||||
gnumake
|
||||
flex
|
||||
bison
|
||||
pkg-config
|
||||
python3 # for testing
|
||||
];
|
||||
|
||||
buildInputs = [
|
||||
check
|
||||
readline
|
||||
libllvm
|
||||
];
|
||||
|
||||
configurePhase = ''
|
||||
echo NEMU_HOME=$NEMU_HOME
|
||||
echo pwd=$(pwd)
|
||||
mkdir -p $(pwd)/kconfig
|
||||
WORK_DIR=$(pwd) obj=$(pwd)/kconfig make --trace -e -f scripts/config.mk WORK_DIR=$(pwd) obj=$(pwd)/kconfig rv32_defconfig
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
BUILD_DIR=$out make install
|
||||
'';
|
||||
|
||||
checkPhase = ''
|
||||
BUILD_DIR=$out make test
|
||||
'';
|
||||
|
||||
NEMU_HOME = src;
|
||||
|
||||
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; [ ];
|
||||
};
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
@ -48,6 +48,9 @@ menuconfig: $(MCONF) $(CONF) $(FIXDEP)
|
|||
savedefconfig: $(CONF)
|
||||
$(Q)$< $(silent) --$@=configs/defconfig $(Kconfig)
|
||||
|
||||
alldefconfig: $(CONF) $(FIXDEP)
|
||||
$(Q)$(CONF) $(silent) --$@ $(Kconfig)
|
||||
|
||||
%defconfig: $(CONF) $(FIXDEP)
|
||||
$(Q)$< $(silent) --defconfig=configs/$@ $(Kconfig)
|
||||
$(Q)$< $(silent) --syncconfig $(Kconfig)
|
||||
|
@ -60,7 +63,7 @@ help:
|
|||
@echo ' savedefconfig - Save current config as configs/defconfig (minimal config)'
|
||||
|
||||
distclean: clean
|
||||
-@rm -rf $(rm-distclean)
|
||||
-rm -rf $(rm-distclean)
|
||||
|
||||
.PHONY: help distclean
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue