I’m trying to build the riscv-toolchain for practice.( I know there is a cross compile tool in nix but just for practice purpose ). So I wrote a simple nix expression below.
let riscv_toolchain = with import <nixpkgs>{};
stdenv.mkDerivation {
name = "riscv_toolchain";
src = fetchFromGitHub{
owner = "riscv";
repo = "riscv-gnu-toolchain";
rev = "b39e36160aa0649ba0dfb9aa314d375900d610fb";
sha256 = "sha256-MI3DesAnMDVJ9VQ6QmoLOt4dnGMdjS32sUQcVBCJoYU=";
};
buildInputs = [ gmp libmpc mpfr gawk bison flex texinfo gperf curl git flock ];
};
in
with import <nixpkgs> {};
mkShell {
packages = [
riscv_toolchain
coreutils
git
];
}
However the building process failed and here is the output.
error: builder for '/nix/store/jqxn1sfd380kgi45fwjr2npxljqj2vq6-riscv_toolchain.drv' failed with exit code 2;
last 10 log lines:
> config.status: creating scripts/wrapper/sed/sed
> building
> build flags: SHELL=/nix/store/xx5s0rkx3aav3f850ig4afadg6ms7lq9-bash-5.2-p15/bin/bash
> cd /private/tmp/nix-build-riscv_toolchain.drv-0/source && \
> flock `git rev-parse --git-dir`/config git submodule init /private/tmp/nix-build-riscv_toolchain.drv-0/source/riscv-gcc/ && \
> flock `git rev-parse --git-dir`/config git submodule update /private/tmp/nix-build-riscv_toolchain.drv-0/source/riscv-gcc/
> fatal error: Not a git repository (or any of the parent directories): .git
> flock: cannot open lock file /config: Read-only file system
> flock: could not create file: Read-only file system
> make: *** [Makefile:247: /private/tmp/nix-build-riscv_toolchain.drv-0/source/riscv-gcc/.git] Error 73
For full logs, run 'nix-store -l /nix/store/jqxn1sfd380kgi45fwjr2npxljqj2vq6-riscv_toolchain.drv'.
I guess maybe the makefile want to config the toolchain file which located in the store directory. But I can’t solve it. Anyone can do me a favor? Thanks very much