forked from openebs/mayastor-control-plane
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshell.nix
89 lines (84 loc) · 2.78 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
{ norust ? false, rust-profile ? "nightly", io-engine ? "" }:
let
sources = import ./nix/sources.nix;
pkgs = import sources.nixpkgs {
overlays = [ (_: _: { inherit sources; }) (import ./nix/overlay.nix { }) ];
};
in
with pkgs;
let
norust_moth =
"You have requested an environment without rust, you should provide it!";
io-engine-moth = "Using the following io-engine binary: ${io-engine}";
channel = import ./nix/lib/rust.nix { inherit sources; };
# python environment for tests/bdd
pytest_inputs = python3.withPackages
(ps: with ps; [ virtualenv grpcio grpcio-tools black ]);
rust_chan = channel.default_src;
in
mkShell {
name = "control-plane-shell";
buildInputs = [
cargo-expand
cargo-udeps
clang
commitlint
cowsay
docker
e2fsprogs
etcd
fio
git
jq
libxfs
llvmPackages.libclang
nvme-cli
openapi-generator
openssl
pkg-config
pre-commit
pytest_inputs
python3
tini
udev
utillinux
which
] ++ pkgs.lib.optional (!norust) rust_chan.${rust-profile};
LIBCLANG_PATH = "${llvmPackages.libclang.lib}/lib";
PROTOC = "${protobuf}/bin/protoc";
PROTOC_INCLUDE = "${protobuf}/include";
# variables used to easily create containers with docker files
ETCD_BIN = "${pkgs.etcd}/bin/etcd";
# using the nix rust toolchain
USE_NIX_RUST = "${toString (!norust)}";
# copy the rust-src to a writable directory, see: https://github.com/rust-lang/cargo/issues/10096
RUST_SRC_CLONE = "/tmp/rust-src";
NODE_PATH = "${nodePackages."@commitlint/config-conventional"}/lib/node_modules";
shellHook = ''
./scripts/nix/git-submodule-init.sh
${pkgs.lib.optionalString (norust) "cowsay ${norust_moth}"}
${pkgs.lib.optionalString (norust) "echo 'Hint: use rustup tool.'"}
${pkgs.lib.optionalString (norust) "echo"}
if [ -n "$USE_NIX_RUST" ]; then
RUST_SRC_PATH="${rust_chan.nightly_src}/lib/rustlib/src/rust/library/"
if ! diff -r "$RUST_SRC_PATH" "$RUST_SRC_CLONE" &>/dev/null; then
rm -rf "$RUST_SRC_CLONE"
mkdir -p "$RUST_SRC_CLONE" 2>/dev/null
cp -r "$RUST_SRC_PATH"/* "$RUST_SRC_CLONE"
chmod -R 775 "$RUST_SRC_CLONE"
fi
fi
pre-commit install
pre-commit install --hook commit-msg
export WORKSPACE_ROOT=`pwd`
[ ! -z "${io-engine}" ] && cowsay "${io-engine-moth}"
[ ! -z "${io-engine}" ] && export IO_ENGINE_BIN="${io-engine-moth}"
export PATH="$PATH:$(pwd)/target/debug"
DOCKER_CONFIG=~/.docker/config.json
if [ -f "$DOCKER_CONFIG" ]; then
DOCKER_TOKEN=$(cat ~/.docker/config.json | jq '.auths."https://index.docker.io/v1/".auth // empty' | tr -d '"' | base64 -d)
export DOCKER_USER=$(echo $DOCKER_TOKEN | cut -d':' -f1)
export DOCKER_PASS=$(echo $DOCKER_TOKEN | cut -d':' -f2)
fi
'';
}