Skip to content

Commit 4784f2e

Browse files
committed
shell.nix: Add nix shell
1 parent cda8737 commit 4784f2e

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

shell.nix

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Licensed under the Apache License, Version 2.0 or the MIT License.
2+
# SPDX-License-Identifier: Apache-2.0 OR MIT
3+
# Copyright Tock Contributors 2022.
4+
5+
# Shell expression for the Nix package manager
6+
#
7+
# This nix expression creates an environment with necessary packages installed:
8+
#
9+
# * rust
10+
#
11+
# To use:
12+
#
13+
# $ nix-shell
14+
#
15+
16+
{ pkgs ? import <nixpkgs> {}, withUnfreePkgs ? false }:
17+
18+
with builtins;
19+
let
20+
inherit (pkgs) stdenv lib;
21+
22+
rust_overlay = import (builtins.fetchTarball "https://github.com/oxalica/rust-overlay/archive/master.tar.gz");
23+
nixpkgs = import <nixpkgs> { overlays = [ rust_overlay ]; };
24+
25+
# Get a custom cross-compile capable Rust install of a specific channel and
26+
# build. Tock expects a specific version of Rust with a selection of targets
27+
# and components to be present.
28+
rustBuild = (
29+
nixpkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml
30+
);
31+
32+
in
33+
pkgs.mkShell {
34+
name = "tock-dev";
35+
36+
buildInputs = with pkgs; [
37+
# --- Toolchains ---
38+
rustBuild
39+
openocd
40+
41+
# --- Convenience and support packages ---
42+
python3Full
43+
tockloader
44+
45+
# Required for tools/print_tock_memory_usage.py
46+
python3Packages.cxxfilt
47+
48+
49+
# --- CI support packages ---
50+
qemu
51+
];
52+
53+
LD_LIBRARY_PATH="${stdenv.cc.cc.lib}/lib64:$LD_LIBRARY_PATH";
54+
55+
# Instruct the Tock gnumake-based build system to not check for rustup and
56+
# assume all requirend tools are installed and available in the $PATH
57+
NO_RUSTUP = "1";
58+
59+
# The defaults "objcopy" and "objdump" are wrong (stem from the standard
60+
# environment for x86), use "llvm-obj{copy,dump}" as defined in the makefile
61+
shellHook = ''
62+
unset OBJCOPY
63+
unset OBJDUMP
64+
'';
65+
}

0 commit comments

Comments
 (0)