From eed328e68a6948e7d9d5604998fced973941ef7b Mon Sep 17 00:00:00 2001 From: Artturin Date: Fri, 21 Feb 2025 17:04:56 +0200 Subject: [PATCH] Fix shell.nix ``` [nix-shell:~/joyofhardware/RiscV-Formal]$ riscv64-unknown-linux-gnu-gcc bash: /nix/store/xq4q2vv9ii7z2k2qp82jd180xdb0r4fv-gcc-riscv64-unknown-linux-gnu-14-20241116/bin/riscv64-unknown-linux-gnu-gcc: cannot execute binary file: Exec format error ``` `pkgs.pkgsCross.riscv64` is for running on riscv64 `pkgs.pkgsCross.riscv64.buildPackages` is for running on the build system and compiling code for riscv64 `nativeBuildInputs` is for packages which run on the build system and compile code for riscv64 with `__splicedPackages` we can avoid having to specify `buildPackages` and have the dependency attributes (`nativeBuildInputs`) pick the `buildHost` version of the package --- shell.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/shell.nix b/shell.nix index fb93d74..f5f7ad1 100644 --- a/shell.nix +++ b/shell.nix @@ -1,10 +1,10 @@ { pkgs ? import {} }: let - riscv64-linux = pkgs.pkgsCross.riscv64; + riscv64-linux = pkgs.pkgsCross.riscv64.__splicedPackages; in pkgs.mkShell { - buildInputs = [ + nativeBuildInputs = [ riscv64-linux.gcc riscv64-linux.binutils riscv64-linux.glibc @@ -13,4 +13,4 @@ pkgs.mkShell { shellHook = '' echo "RISC-V Linux cross-compilation environment initialized!" ''; -} \ No newline at end of file +}