Skip to content

Commit 37d25b8

Browse files
committed
Add a shell.nix file to provide toolchains.
1 parent c6b5def commit 37d25b8

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

shell.nix

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# This file defines two Nix shells, one with a RISC-V 32-bit toolchain, the
2+
# other is 64-bit. The approach is outlined at
3+
# https://nixos.wiki/wiki/Cross_Compiling.
4+
#
5+
# Usage:
6+
#
7+
# nix-shell --attr riscv32
8+
#
9+
# then use `riscv32-none-elf-gcc` as compiler, or
10+
#
11+
# nix-shell --attr riscv64
12+
#
13+
# then use `riscv64-unknown-linux-gnu-gcc` as compiler.
14+
15+
{ pkgs ? import <nixpkgs> {} }:
16+
17+
let
18+
riscv32-pkgs = import <nixpkgs> {
19+
crossSystem = (import <nixpkgs/lib>).systems.examples.riscv32-embedded;
20+
};
21+
22+
riscv64-pkgs = import <nixpkgs> {
23+
crossSystem = (import <nixpkgs/lib>).systems.examples.riscv64;
24+
};
25+
26+
in
27+
{
28+
riscv32 = riscv32-pkgs.mkShell {
29+
buildInputs = [
30+
];
31+
};
32+
33+
riscv64 = riscv64-pkgs.mkShell {
34+
buildInputs = [
35+
];
36+
nativeBuildInputs = [
37+
# Uncomment to also bring QEMU, if you don't have it system-wide.
38+
# riscv64-pkgs.buildPackages.buildPackages.qemu
39+
riscv64-pkgs.buildPackages.gdb
40+
];
41+
};
42+
}

0 commit comments

Comments
 (0)