-
Notifications
You must be signed in to change notification settings - Fork 0
/
shell.nix
100 lines (83 loc) · 2.81 KB
/
shell.nix
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# Shell expression for the Nix package manager
#
# This nix expression creates an environment with necessary packages installed:
#
# * `tockloader`
# * rust
#
# To use:
#
# $ nix-shell
#
{ pkgs ? import <nixpkgs> {} }:
with builtins;
let
inherit (pkgs) stdenv lib;
pythonPackages = lib.fix' (self: with self; pkgs.python3Packages //
{
tockloader = buildPythonPackage rec {
pname = "tockloader";
version = "1.8.0";
name = "${pname}-${version}";
propagatedBuildInputs = [ argcomplete colorama crcmod pyserial pytoml tqdm ];
src = fetchPypi {
inherit pname version;
sha256 = "0qniwkhgiwm9bayf1l9s3i83k0f7qm0iqgvjljdj4pf86lqllbb7";
};
};
});
moz_overlay = import (builtins.fetchTarball https://github.com/mozilla/nixpkgs-mozilla/archive/master.tar.gz);
nixpkgs = import <nixpkgs> { overlays = [ moz_overlay ]; };
# Get a custom cross-compile capable Rust install of a specific channel and
# build. Tock expects a specific version of Rust with a selection of targets
# and components to be present.
rustBuild = (
nixpkgs.rustChannelOf (
let
# Read the ./rust-toolchain (and trim whitespace) so we can extrapolate
# the channel and date information. This makes it more convenient to
# update the Rust toolchain used.
rustToolchain = builtins.replaceStrings ["\n" "\r" " " "\t"] ["" "" "" ""] (
builtins.readFile ./rust-toolchain
);
in
{
channel = lib.head (lib.splitString "-" rustToolchain);
date = lib.concatStringsSep "-" (lib.tail (lib.splitString "-" rustToolchain));
}
)
).rust.override {
targets = [
"thumbv7em-none-eabi" "thumbv7em-none-eabihf" "thumbv6m-none-eabi"
"riscv32imac-unknown-none-elf" "riscv32imc-unknown-none-elf" "riscv32i-unknown-none-elf"
];
extensions = [
"rust-src" # required to compile the core library
"llvm-tools-preview" # currently required to support recently added flags
];
};
in
pkgs.mkShell {
name = "tock-dev";
buildInputs = with pkgs; [
# --- Toolchains ---
rustBuild
# --- Convenience and support packages ---
python3Full
pythonPackages.tockloader
# Required for tools/print_tock_memory_usage.py
pythonPackages.cxxfilt
# --- CI support packages ---
qemu
];
LD_LIBRARY_PATH="${stdenv.cc.cc.lib}/lib64:$LD_LIBRARY_PATH";
# Instruct the Tock gnumake-based build system to not check for rustup and
# assume all requirend tools are installed and available in the $PATH
NO_RUSTUP = "1";
# The defaults "objcopy" and "objdump" are wrong (stem from the standard
# environment for x86), use "llvm-obj{copy,dump}" as defined in the makefile
shellHook = ''
unset OBJCOPY
unset OBJDUMP
'';
}