forked from efabless/caravel_board
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshell.nix
More file actions
42 lines (39 loc) · 1.27 KB
/
shell.nix
File metadata and controls
42 lines (39 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
{ pkgs ? import <nixpkgs> { } }:
let
pythonPackages = pkgs.python3Packages;
# Create a custom package set for cross-compilation to RISC-V
riscvPkgs = import <nixpkgs> {
crossSystem = {
config = "riscv32-none-elf";
libc = "newlib";
# Specify the exact RISC-V architecture features you need
# This matches your Makefile TARGET_ARCH settings
gcc = {
arch = "rv32i";
abi = "ilp32";
};
};
};
# Use overrideAttrs to directly modify the derivation attributes
customRiscvGcc = riscvPkgs.buildPackages.gcc.overrideAttrs (oldAttrs: {
configureFlags = (oldAttrs.configureFlags or [ ])
++ [ "--enable-multilib" "--with-multilib-generator=rv32i-ilp32--" ];
});
in pkgs.mkShell {
# Include both the custom cross-compiler and other tools you might need
buildInputs = [
customRiscvGcc
# Additional tools that might be helpful
pkgs.gnumake
pkgs.python3 # Useful for any build scripts
pythonPackages.pyftdi
pkgs.busybox
];
# Set up environment variables
shellHook = ''
export RISCV_PREFIX="riscv32-none-elf-"
export PATH=${customRiscvGcc}/bin:$PATH
echo "RISC-V GCC Cross-compiler environment loaded!"
echo "Compiler version: $(riscv32-none-elf-gcc --version | head -n 1)"
'';
}