Repository navigation
Expand file tree
/
Copy pathshell.nix
More file actions
182 lines (167 loc) · 6.3 KB
/
Copy pathshell.nix
File metadata and controls
182 lines (167 loc) · 6.3 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# Nix development shell for Tarantool,
# https://www.tarantool.io/en/doc/latest/contributing/building_from_source/
#
# Usage without flakes:
# nix-shell # Enter development environment.
# nix-shell --pure # Enter pure (isolated) environment.
#
# With flakes, `nix develop' imports this file; see flake.nix.
#
{
# Use the nixpkgs revision pinned in flake.lock, so that `nix-shell' and
# `nix develop' provide the same toolchain.
pkgs ? import (builtins.fetchTree (builtins.fromJSON (
builtins.readFile ./flake.lock
)).nodes.nixpkgs.locked) { },
# Taken from the upstream flake through flake.nix to get a version
# newer than the one in nixpkgs. The defaults keep `nix-shell` usable.
emmyluaCheck ? pkgs.emmylua-check,
emmyluaDocCli ? pkgs.emmylua-doc-cli,
# Taken from the upstream flake through flake.nix. The default keeps
# `nix-shell` usable with the same pinned revision.
checkpatchSrc ? pkgs.fetchFromGitHub {
owner = "tarantool";
repo = "checkpatch";
rev = "4801da8d408fc4c511c690c3575768b9a7c5810c";
hash = "sha256-P3WUKgJl6NLNPPqOi0YTLNuEyh6n2J8ZpU3AWMP0cfo=";
},
}:
let
# The common symbolizer used by sanitizers to symbolize reports.
# Sanitizers look for the `llvm-symbolizer' binary in PATH, which
# is provided by the `llvm' package (see buildInputs below).
symbolizer = "${pkgs.llvmPackages_latest.llvm}/bin/llvm-symbolizer";
ccLibPath = pkgs.lib.makeLibraryPath [ pkgs.stdenv.cc.cc.lib ];
pythonEnv = pkgs.python3.withPackages (
# numpy and scipy are needed by perf/tools/compare/compare.py,
# gevent, pyyaml and six are needed by test-run/test-run.py.
ps: with ps; [
gevent
numpy
pyyaml
scipy
six
]
);
# checkpatch.pl is not packaged in nixpkgs, so take the Tarantool fork
# used by CI. `--codespellfile' is passed explicitly because the script
# otherwise looks for the dictionary under /usr/share, which does not
# exist in Nix.
codespellDict = pkgs.lib.concatStrings [
"${pkgs.codespell}/${pkgs.python3.sitePackages}"
"/codespell_lib/data/dictionary.txt"
];
checkpatch = pkgs.writeShellScriptBin "checkpatch.pl" ''
exec ${pkgs.perl}/bin/perl ${checkpatchSrc}/checkpatch.pl \
--codespellfile ${codespellDict} \
"$@"
'';
# `taskset' pins a perf test process to a CPU for stable results. Only
# the binary is wrapped because util-linux ships many other utils which
# would shadow the system ones.
taskset = pkgs.writeShellScriptBin "taskset" ''
exec ${pkgs.util-linux}/bin/taskset "$@"
'';
# Build dependencies shared with the Tarantool derivations in
# flake.nix, which reuse them through `passthru.buildDeps'
# below. The commented CMake options select the system libraries;
# for a shared build most of them are the default.
buildDeps = {
nativeBuildInputs = with pkgs; [
cmake
git # third_party/luajit/cmake/SetVersion.cmake
];
buildInputs = with pkgs; [
c-ares # Used by the bundled libcurl sub-build.
icu # -DENABLE_BUNDLED_ICU=OFF
nghttp2 # Used by the bundled libcurl sub-build.
openssl # -DENABLE_BUNDLED_OPENSSL=OFF
readline # -DENABLE_BUNDLED_READLINE=OFF
zlib # -DENABLE_BUNDLED_ZLIB=OFF
];
};
# Extra Tarantool dependencies for the development shell. They
# are not required to build the `tarantool` package because
# Tarantool bundles libcurl and libyaml, and on Linux iconv
# comes from libc. Providing them lets the bundled libraries be
# replaced with the system ones via the commented CMake options.
systemLibs = with pkgs; [
curl # -DENABLE_BUNDLED_LIBCURL=OFF
libiconv # -DENABLE_BUNDLED_ICONV=OFF
libyaml # -DENABLE_BUNDLED_LIBYAML=OFF
];
in
pkgs.mkShell {
name = "tarantool-dev";
inherit (buildDeps) nativeBuildInputs;
buildInputs =
buildDeps.buildInputs
++ systemLibs
++ (with pkgs; [
checkpatch
codespell
doxygen
emmyluaCheck
emmyluaDocCli
gbenchmark
gcc
gnumake
lcov
llvmPackages_latest.clang
llvmPackages_latest.llvm
luajitPackages.luacheck
ninja
stdenv.cc.cc.lib
taskset
# libprotobuf-mutator in lua-tests is pinned to a revision that is
# incompatible with protobuf >= 22.
protobuf_21
# libprotobuf-mutator examples use find_package(LibLZMA).
xz
# Python environment with packages required for regression
# testing.
pythonEnv
]);
passthru.buildDeps = buildDeps;
env = {
LD_LIBRARY_PATH = ccLibPath;
# clang finds the GCC toolchain but not libstdc++.so from the
# separate gcc-*-lib output. LuaJIT's ASan test builds LD_PRELOAD
# via `cc -print-file-name=libstdc++.so`, which needs it.
COMPILER_PATH = ccLibPath;
# Point sanitizers (ASan, MSan, UBSan) to the LLVM symbolizer,
# so that error reports contain function names and line numbers
# even if PATH is changed within a session.
MSAN_SYMBOLIZER_PATH = symbolizer;
ASAN_SYMBOLIZER_PATH = symbolizer;
UBSAN_SYMBOLIZER_PATH = symbolizer;
};
# luatest is shipped as the `luatest` git submodule and is wired up
# by test-run's wrapper, which injects ../luatest into package.path.
# Export the same paths so that the `luatest` command and
# require('luatest') work in the shell.
shellHook = ''
REPO=$(git rev-parse --show-toplevel 2>/dev/null) || REPO=$PWD
# The nixpkgs cmake hook only passes the build input prefixes to
# cmakeConfigurePhase, so export them for a manually run cmake.
# Config-mode packages (benchmark, for instance) need this.
cmake_prefix_path="$NIXPKGS_CMAKE_PREFIX_PATH"
if [ -n "''${CMAKE_PREFIX_PATH:-}" ]; then
cmake_prefix_path="$cmake_prefix_path:$CMAKE_PREFIX_PATH"
fi
export CMAKE_PREFIX_PATH="$cmake_prefix_path"
export PATH="$REPO/test-run/bin:$PATH"
export CTEST_PARALLEL_LEVEL=$(getconf _NPROCESSORS_ONLN)
export LUA_PATH="''${LUA_PATH:-;}"
export LUA_PATH="$REPO/luatest/?.lua;$REPO/luatest/?/init.lua;$LUA_PATH"
export PYTHONPATH="$REPO/src:$PYTHONPATH"
echo
echo "Tarantool Development Environment"
echo
echo "List all available CMake workflow presets:"
echo " cmake --workflow --list-presets"
echo
echo "Execute a predefined sequence of CMake actions:"
echo " cmake --workflow --preset clang_debug_asan"
'';
}