This repository has been archived by the owner on Jun 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.nix
128 lines (110 loc) · 2.85 KB
/
build.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
{ pkgs, mysql-src, rocksdb-src, version }:
with pkgs;
with stdenv;
let
rocksdb = mkDerivation rec {
name = "rocksdb";
src = rocksdb-src;
nativeBuildInputs = [ cmake ninja ];
buildInputs = [ lz4 zlib zstd jemalloc liburing numactl tbb ];
cmakeFlags = [
"-DPORTABLE=0"
"-DFAIL_ON_WARNINGS=YES"
"-DFORCE_SSE42=1"
"-DUSE_RTTI=1"
"-DWITH_BENCHMARK_TOOLS=0"
"-DWITH_BZ2=0"
"-DWITH_GFLAGS=0"
"-DWITH_JEMALLOC=1"
"-DWITH_JNI=0"
"-DWITH_LZ4=1"
"-DWITH_NUMA=1"
"-DWITH_SNAPPY=0"
"-DWITH_TBB=1"
"-DWITH_TESTS=1"
"-DWITH_TOOLS=0"
"-DWITH_ZLIB=1"
"-DWITH_ZSTD=1"
];
NIX_CFLAGS_COMPILE = "-DLIBURING -DROCKSDB_IOURING_PRESENT -Wno-error=deprecated-copy -Wno-error=pessimizing-move";
NIX_LDFLAGS = "-luring";
};
self = mkDerivation rec {
inherit version;
pname = "mysql";
src = mysql-src;
nativeBuildInputs = [ bison cmake pkgconfig rpcsvc-proto makeWrapper ];
buildInputs = [
icu
libedit
libevent
ncurses
openssl
re2
readline
zlib
lz4
numactl
libtirpc
bash
boost170
coreutils
gnumake
libaio
perl
protobuf3_6
rocksdb
zstd
];
outputs = [ "out" "static" ];
patches = [
./patches/nixos.patch
];
cmakeFlags = [
"-DCMAKE_BUILD_TYPE=Release"
"-DBUILD_CONFIG=mysql_release"
"-DFEATURE_SET=community"
"-DHAVE_EXTERNAL_ROCKSDB=ON"
"-DROCKSDB_SRC_PATH=${rocksdb-src}"
"-DWITH_SYSTEM_LIBS=ON"
"-DWITH_LZ4=system"
"-DWITH_ZSTD=system"
"-DWITH_NUMA=ON"
"-DCMAKE_SKIP_BUILD_RPATH=OFF" # To run libmysql/libmysql_api_test during build.
"-DWITH_UNIT_TESTS=OFF"
"-DINSTALL_DOCDIR=share/mysql/docs"
"-DINSTALL_DOCREADMEDIR=share/mysql"
"-DINSTALL_INCLUDEDIR=include/mysql"
"-DINSTALL_INFODIR=share/mysql/docs"
"-DINSTALL_MANDIR=share/man"
"-DINSTALL_MYSQLSHAREDIR=share/mysql"
"-DINSTALL_MYSQLTESTDIR="
"-DINSTALL_PLUGINDIR=lib/mysql/plugin"
"-DINSTALL_SHAREDIR=share/mysql"
"-DINSTALL_SUPPORTFILESDIR=share/mysql"
"-DMYSQL_DATADIR=/var/mysql"
"-DMYSQL_UNIX_ADDR=/run/mysqld/mysqld.sock"
"-DMYSQL_GITHASH=${mysql-src.rev}"
"-DMYSQL_GITDATE=${mysql-src.lastModifiedDate}"
"-DROCKSDB_GITHASH=${rocksdb-src.rev}"
"-DROCKSDB_GITDATE=${rocksdb-src.lastModifiedDate}"
];
NIX_LDFLAGS = "-lrocksdb";
enableParallelBuilding = true;
preBuild = ''
patchShebangs .
'';
postInstall = ''
moveToOutput "lib/*.a" $static
ln -s libmysqlclient.so $out/lib/libmysqlclient_r.so
chmod go-w $out
'';
passthru = {
client = self;
connector-c = self;
server = self;
mysqlVersion = "8.0";
};
};
in
self