feat(nix): add nix devshell support (#60)
Basically, just do whatever
setup-tools.sh
does, using nix.We can run
nix develop
to enter devshells.Also, we can use nix-direnv and run
direnv allow .
to let direnv auto management.I’ll add docs to XiangShan-doc if needed.
Showcase using direnv:
$ direnv allow workspace/xs-env # this will be needed only the first time $ cd workspace/xs-env/XiangShan # direnv will build & activate devshell each time you enter xs-env and subdirectories direnv: loading ~/workspace/xs-env/.envrc direnv: using flake === Welcome to XiangShan devshell! === Version info: - Verilator 5.028 2024-08-21 rev v5.028 - Mill Build Tool version 0.12.3 - gcc (GCC) 14.2.1 20250322 - riscv64-unknown-linux-gnu-gcc (GCC) 14.2.1 20250322 - openjdk version "21.0.7" 2025-04-15 You can press Ctrl + D to exit devshell. direnv: export +AR +AS +CC +CLASSPATH +CONFIG_SHELL +CXX +DETERMINISTIC_BUILD +HOST_PATH +IN_NIX_SHELL +JAVA_HOME +LD +NIX_BINTOOLS +NIX_BINTOOLS_WRAPPER_TARGET_HOST_riscv64_unknown_linux_gnu +NIX_BINTOOLS_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu +NIX_BUILD_CORES +NIX_BUILD_TOP +NIX_CC +NIX_CC_WRAPPER_TARGET_HOST_riscv64_unknown_linux_gnu +NIX_CC_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu +NIX_CFLAGS_COMPILE +NIX_ENFORCE_NO_NATIVE +NIX_HARDENING_ENABLE +NIX_LDFLAGS +NIX_STORE +NM +OBJCOPY +OBJDUMP +PYTHONHASHSEED +PYTHONNOUSERSITE +PYTHONPATH +RANLIB +READELF +SDL2_PATH +SIZE +SOURCE_DATE_EPOCH +STRINGS +STRIP +TEMP +TEMPDIR +TMP +TMPDIR +_PYTHON_HOST_PLATFORM +_PYTHON_SYSCONFIGDATA_NAME +__structuredAttrs +buildInputs +buildPhase +builder +cmakeFlags +configureFlags +depsBuildBuild +depsBuildBuildPropagated +depsBuildTarget +depsBuildTargetPropagated +depsHostHost +depsHostHostPropagated +depsTargetTarget +depsTargetTargetPropagated +doCheck +doInstallCheck +dontAddDisableDepTrack +mesonFlags +name +nativeBuildInputs +out +outputs +patches +phases +preferLocalBuild +propagatedBuildInputs +propagatedNativeBuildInputs +shell +shellHook +stdenv +strictDeps +system ~PATH ~XDG_DATA_DIRS $
XiangShan Frontend Develop Environment
TLDR
使用以下脚本来布署香山开发环境,**部署脚本只需运行一次.**:
This script will setup XiangShan develop environment automatically. Note that
./setup-tools.sh
andsetup.sh
only need to be run ONCE.由于香山
master
分支更新频繁,此仓库中的 submodule 默认追踪香山主线分支上的一个稳定提交,并不是香山及其他工具的最新版本。要更新各子仓库到最新版本,可以运行:Due to the frequent updates of the Xiangshan
master
branch, the submodule in this repo tracks a stable commit on the Xiangshan master branch by default, not the latest version of Xiangshan and the other tools. To update each submodule to the latest version, run:环境部署成功后,每次要使用开发环境时,只需使用以下命令配置环境变量:
After XiangShan Develop Environment setup, use the following script every time before using XiangShan Develop Environment.
Document
详细使用方式请参考完整文档:
For further instructions, see:
XiangShan Frontend Develop Environment Document