Skip to content

Commit a56ccd5

Browse files
committed
add dual toolchains
1 parent 4784f2e commit a56ccd5

File tree

2 files changed

+43
-2
lines changed

2 files changed

+43
-2
lines changed

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,17 @@ test: examples
114114
--target=thumbv7em-none-eabi --workspace
115115
LIBTOCK_PLATFORM=hifive1 cargo clippy $(EXCLUDE_STD) \
116116
--target=riscv32imac-unknown-none-elf --workspace
117+
# example bash logic
118+
if [ "${NO_RUSTUP}" = "1" ]; then
119+
use_nightly_toolchain
120+
fi
117121
cd nightly && \
118122
MIRIFLAGS="-Zmiri-strict-provenance -Zmiri-symbolic-alignment-check" \
119123
cargo miri test $(EXCLUDE_MIRI) --manifest-path=../Cargo.toml \
120124
--target-dir=target --workspace
125+
if [ "${NO_RUSTUP}" = "1" ]; then
126+
use_stable_toolchain
127+
fi
121128
echo '[ SUCCESS ] libtock-rs tests pass'
122129

123130
# Helper functions to define make targets to build for specific (flash, ram,

shell.nix

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#
77
# This nix expression creates an environment with necessary packages installed:
88
#
9+
# * `tockloader`
910
# * rust
1011
#
1112
# To use:
@@ -19,14 +20,31 @@ with builtins;
1920
let
2021
inherit (pkgs) stdenv lib;
2122

22-
rust_overlay = import (builtins.fetchTarball "https://github.com/oxalica/rust-overlay/archive/master.tar.gz");
23+
# Tockloader v1.11.0
24+
tockloader = import (pkgs.fetchFromGitHub {
25+
owner = "tock";
26+
repo = "tockloader";
27+
rev = "v1.11.0";
28+
sha256 = "sha256-bPEfpfOZOjOiazqRgn1cnqe4ohLPvocuENKoZx/Qw80=";
29+
}) { inherit pkgs withUnfreePkgs; };
30+
31+
rust_overlay = import "${pkgs.fetchFromGitHub {
32+
owner = "nix-community";
33+
repo = "fenix";
34+
rev = "1a92c6d75963fd594116913c23041da48ed9e020";
35+
sha256 = "sha256-L3vZfifHmog7sJvzXk8qiKISkpyltb+GaThqMJ7PU9Y=";
36+
}}/overlay.nix";
37+
2338
nixpkgs = import <nixpkgs> { overlays = [ rust_overlay ]; };
2439

2540
# Get a custom cross-compile capable Rust install of a specific channel and
2641
# build. Tock expects a specific version of Rust with a selection of targets
2742
# and components to be present.
2843
rustBuild = (
29-
nixpkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml
44+
nixpkgs.fenix.fromToolchainFile { file = ./rust-toolchain.toml; }
45+
);
46+
rustBuildNightly = (
47+
nixpkgs.fenix.fromToolchainFile { file = ./nightly/rust-toolchain.toml; }
3048
);
3149

3250
in
@@ -36,6 +54,7 @@ in
3654
buildInputs = with pkgs; [
3755
# --- Toolchains ---
3856
rustBuild
57+
rustBuildNightly
3958
openocd
4059

4160
# --- Convenience and support packages ---
@@ -48,6 +67,18 @@ in
4867

4968
# --- CI support packages ---
5069
qemu
70+
71+
# --- Flashing tools ---
72+
# If your board requires J-Link to flash and you are on NixOS,
73+
# add these lines to your system wide configuration.
74+
75+
# Enable udev rules from segger-jlink package
76+
# services.udev.packages = [
77+
# pkgs.segger-jlink
78+
# ];
79+
80+
# Add "segger-jlink" to your system packages and accept the EULA:
81+
# nixpkgs.config.segger-jlink.acceptLicense = true;
5182
];
5283

5384
LD_LIBRARY_PATH="${stdenv.cc.cc.lib}/lib64:$LD_LIBRARY_PATH";
@@ -61,5 +92,8 @@ in
6192
shellHook = ''
6293
unset OBJCOPY
6394
unset OBJDUMP
95+
96+
alias use_stable_toolchain=PATH=${rustBuild}/bin:$PATH
97+
alias use_nightly_toolchain=PATH=${rustBuildNightly}/bin:$PATH
6498
'';
6599
}

0 commit comments

Comments
 (0)