-
Notifications
You must be signed in to change notification settings - Fork 127
Expand file tree
/
Copy pathshell.nix
More file actions
99 lines (85 loc) · 2.84 KB
/
shell.nix
File metadata and controls
99 lines (85 loc) · 2.84 KB
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
{ rust ? (let v = builtins.getEnv "NIX_RUST"; in if v == "" then "stable" else v)
, spdk ? (let v = builtins.getEnv "NIX_SPDK"; in if v == "" then "develop" else v)
, spdk-path ? (let v = builtins.getEnv "NIX_SPDK_PATH"; in if v == "" then null else v)
} @ args:
let
sources = import ./nix/sources.nix;
pkgs = import sources.nixpkgs {
overlays = [
(_: _: { inherit sources; })
(import ./nix/overlay.nix { })
];
};
# python environment for test/python
pytest_inputs = with pkgs; python3.withPackages
(ps: with ps; [ virtualenv grpcio grpcio-tools asyncssh black ]);
nix-file = "\\$" + "{workspaceFolder}/shell.nix";
nix-spdk-path = if spdk-path != null then " --argstr spdk-path $(realpath ${toString spdk-path})" else "";
shellAttrs = import ./spdk-rs/nix/shell {
inherit rust;
inherit spdk;
inherit spdk-path;
inherit sources;
inherit pkgs;
cfg = {
buildInputs = with pkgs; [
docker
docker-compose
e2fsprogs
etcd
gdb
git
gnuplot
kubernetes-helm
nodejs-slim
numactl
pytest_inputs
udev
libnvme
nvme-cli
xfsprogs
nixpkgs-fmt
ublksrv
];
shellEnv = with pkgs; {
PROTOC = io-engine.PROTOC;
PROTOC_INCLUDE = io-engine.PROTOC_INCLUDE;
ETCD_BIN = "${etcd}/bin/etcd";
LVM_BINS = "${lvm2.bin}/bin";
NVME = "${nvme-cli}/bin/nvme";
# Dummy values in case environment does not have /etc/nvme
NVME_HOSTID = "03f79caf-dc58-475a-a111-bf0b75214a51";
NVME_HOSTNQN = "nqn.2014-08.org.nvmexpress:uuid:03f79caf-dc58-475a-a111-bf0b75214a51";
# Env vars to allow for better integration with code editors which use a nix environment selector
NIX_RUST = rust;
NIX_SPDK = spdk;
NIX_SPDK_PATH = toString spdk-path;
};
shellHook = ''
# SRCDIR is needed by docker-compose files as it requires absolute paths
export SRCDIR=`pwd`
export PATH="$PATH:$(pwd)/scripts/nix-sudo"
export IO_ENGINE_DIR="$RUST_TARGET_DEBUG"
# Prevent Rust tooling to fallback to potentially incompatible host clang compiler
export CLANG_PATH="$NIX_CC_FOR_TARGET/bin/clang"
cat > "$SRCDIR/.vscode/settings.json" <<EOF
{
"nixEnvSelector.args": "--argstr rust ${rust} --argstr spdk ${spdk}${nix-spdk-path}",
"nixEnvSelector.nixFile": "${toString nix-file}"
}
EOF
'';
shellInfoHook = ''
echo
echo "PROTOC : $PROTOC"
echo "PROTOC_INCLUDE : $PROTOC_INCLUDE"
echo "ETCD_BIN : $ETCD_BIN"
echo "LVM path : $LVM_BINS"
echo "I/O engine dir : $IO_ENGINE_DIR"
'';
};
};
in
pkgs.mkShell shellAttrs // {
name = "io-engine-dev-shell";
}