2019-03-07 23:27:33 +08:00
|
|
|
{ rustChannel ? "nightly" }:
|
|
|
|
|
|
|
|
let
|
|
|
|
mozillaOverlay = import (builtins.fetchTarball https://github.com/mozilla/nixpkgs-mozilla/archive/master.tar.gz);
|
2019-03-18 08:39:02 +08:00
|
|
|
pkgs = import <nixpkgs> { overlays = [ mozillaOverlay ]; };
|
|
|
|
# `lib.systems.examples.armhf-embedded` from nixpkgs master
|
|
|
|
# (TODO: use directly starting with NixOS 19.0X)
|
|
|
|
targetPlatform = {
|
|
|
|
config = "arm-none-eabihf";
|
|
|
|
libc = "newlib";
|
|
|
|
};
|
2019-03-07 23:27:33 +08:00
|
|
|
in
|
2019-03-18 08:39:02 +08:00
|
|
|
with pkgs;
|
2019-03-07 23:27:33 +08:00
|
|
|
let
|
2019-03-20 04:31:46 +08:00
|
|
|
rustPlatform = callPackage (import ./nix/rustPlatform.nix) {};
|
2019-03-08 01:24:21 +08:00
|
|
|
openocd = callPackage (import ./nix/openocd.nix) {};
|
2019-03-18 08:39:02 +08:00
|
|
|
# TODO: gdb 8.2.1 from NixOS >= 19.XX is multiarch by default.
|
|
|
|
# remove the following as `gdb` is already in scope
|
|
|
|
gdb = pkgs.gdb.override {
|
|
|
|
stdenv = stdenv.override {
|
|
|
|
targetPlatform = {
|
|
|
|
config = "arm-none-eabihf";
|
|
|
|
libc = "newlib";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2019-03-07 23:27:33 +08:00
|
|
|
in
|
|
|
|
stdenv.mkDerivation {
|
|
|
|
name = "adc2tcp-env";
|
|
|
|
buildInputs = with rustPlatform.rust; [
|
2019-03-15 21:18:43 +08:00
|
|
|
rustc cargo gdb
|
2019-03-07 23:27:33 +08:00
|
|
|
];
|
|
|
|
|
|
|
|
# Set Environment Variables
|
|
|
|
RUST_BACKTRACE = 1;
|
2019-03-08 01:24:21 +08:00
|
|
|
|
|
|
|
shellHook = ''
|
|
|
|
echo "Starting openocd…"
|
|
|
|
${openocd}/bin/openocd-nucleo-f429zi &
|
|
|
|
|
|
|
|
# Let openocd output scroll by
|
|
|
|
sleep 1
|
|
|
|
|
2019-03-20 00:16:45 +08:00
|
|
|
echo "Run 'cargo run --release --features=semihosting'"
|
2019-03-08 01:24:21 +08:00
|
|
|
'';
|
2019-03-07 23:27:33 +08:00
|
|
|
}
|