forked from scylladb/scylladb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.nix
201 lines (172 loc) · 4.46 KB
/
default.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
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
# Copyright (C) 2021-present ScyllaDB
#
#
# SPDX-License-Identifier: AGPL-3.0-or-later
#
#
# * "nix build" is unsupported (or rather supported up to and not including
# installPhase), so basically all this is just for "nix develop"
#
# * IMPORTANT: to avoid using up ungodly amounts of disk space under
# /nix/store/ when you are not using flakes, make sure to move the
# actual build directory outside this tree and make ./build a
# symlink to it. Or use flakes (seriously, just use flakes).
#
{ flake ? false
, shell ? false
, pkgs ? import <nixpkgs> { system = builtins.currentSystem; overlays = [ (import ./dist/nix/overlay.nix <nixpkgs>) ]; }
, srcPath ? builtins.path { path = ./.; name = "scylla"; }
, repl ? null
, mode ? "release"
, verbose ? false
# shell env will want to add stuff to the environment, and the way
# for it to do so is to pass us a function with this signatire:
, devInputs ? ({ pkgs, llvm }: [])
}:
let
inherit (builtins)
baseNameOf
head
match
split
;
inherit (import (builtins.fetchTarball {
url = "https://github.com/hercules-ci/gitignore/archive/5b9e0ff9d3b551234b4f3eb3983744fa354b17f1.tar.gz";
sha256 = "01l4phiqgw9xgaxr6jr456qmww6kzghqrnbc7aiiww3h6db5vw53";
}) { inherit (pkgs) lib; })
gitignoreSource;
# all later Boost versions are problematic one way or another
boost = pkgs.boost175;
llvm = pkgs.llvmPackages_15;
stdenvUnwrapped = llvm.stdenv;
# define custom ccache- and distcc-aware wrappers for all relevant
# compile drivers (used only in shell env)
cc-wrappers = pkgs.callPackage ./dist/nix/pkg/custom/ccache-distcc-wrap {
cc = stdenvUnwrapped.cc;
clang = llvm.clang;
inherit (pkgs) gcc;
};
stdenv = if shell then pkgs.overrideCC stdenvUnwrapped cc-wrappers
else stdenvUnwrapped;
noNix = path: type: type != "regular" || (match ".*\.nix" path) == null;
src = builtins.filterSource noNix (if flake then srcPath
else gitignoreSource srcPath);
derive = if shell then pkgs.mkShell.override { inherit stdenv; }
else stdenv.mkDerivation;
in derive ({
name = "scylla";
inherit src;
# since Scylla build, as it exists, is not cross-capable, the
# nativeBuildInputs/buildInputs distinction below ranges, depending
# on how charitable one feels, from "pedantic" through
# "aspirational" all the way to "cargo cult ritual" -- i.e. not
# expected to be actually correct or verifiable. but it's the
# thought that counts!
nativeBuildInputs = with pkgs; [
ant
antlr3
boost
cargo
cmake
cxx-rs
gcc
openjdk11_headless
libtool
llvm.bintools
maven
ninja
pkg-config
python2
(python3.withPackages (ps: with ps; [
aiohttp
boto3
colorama
distro
magic
psutil
pyparsing
pytest
pytest-asyncio
pyudev
pyyaml
requests
scylla-driver
setuptools
tabulate
urwid
]))
ragel
rustc
stow
] ++ (devInputs { inherit pkgs llvm; });
buildInputs = with pkgs; [
abseil-cpp
antlr3
boost
c-ares
cryptopp
fmt
gmp
gnutls
hwloc
icu
jsoncpp
libdeflate
libidn2
libp11
libsystemtap
libtasn1
libunistring
liburing
libxcrypt
libxfs
libxml2
libyamlcpp
llvm.compiler-rt
lksctp-tools
lua54Packages.lua
lz4
nettle
numactl
openssl
p11-kit
protobuf
rapidjson
snappy
systemd
valgrind
xorg.libpciaccess
xxHash
zlib
zstd
];
JAVA8_HOME = "${pkgs.openjdk8_headless}/lib/openjdk";
JAVA_HOME = "${pkgs.openjdk11_headless}/lib/openjdk";
}
// (if shell then {
configurePhase = "./configure.py${if verbose then " --verbose" else ""} --disable-dpdk";
} else {
# sha256 of the filtered source tree:
SCYLLA_RELEASE = head (split "-" (baseNameOf src));
postPatch = ''
patchShebangs ./configure.py
patchShebangs ./seastar/scripts/seastar-json2code.py
patchShebangs ./seastar/cooking.sh
'';
configurePhase = "./configure.py${if verbose then " --verbose" else ""} --mode=${mode}";
buildPhase = ''
${pkgs.ninja}/bin/ninja \
build/${mode}/scylla \
build/${mode}/iotune \
'';
# build/${mode}/dist/tar/scylla-tools-package.tar.gz \
# build/${mode}/dist/tar/scylla-jmx-package.tar.gz \
installPhase = ''
echo not implemented 1>&2
exit 1
'';
})
// (if !shell || repl == null then {} else {
REPL = repl;
})
)