2023-04-21 20:40:09 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
|
|
|
, cmake
|
|
|
|
, ninja
|
|
|
|
, python3
|
|
|
|
, perl
|
|
|
|
, yasm
|
2021-11-21 19:38:57 +00:00
|
|
|
, nixosTests
|
2023-05-18 12:41:03 +00:00
|
|
|
|
|
|
|
# currently for BLAKE3 hash function
|
|
|
|
, rustSupport ? true
|
|
|
|
|
|
|
|
, corrosion
|
|
|
|
, rustc
|
|
|
|
, cargo
|
|
|
|
, rustPlatform
|
2018-06-11 08:37:06 +00:00
|
|
|
}:
|
2017-03-27 01:06:23 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
2019-08-15 12:41:18 +00:00
|
|
|
pname = "clickhouse";
|
2023-06-13 08:47:02 +00:00
|
|
|
version = "23.3.3.52";
|
2021-05-08 12:50:53 +00:00
|
|
|
|
2023-06-05 21:39:51 +00:00
|
|
|
src = fetchFromGitHub rec {
|
2023-04-21 20:40:09 +00:00
|
|
|
owner = "ClickHouse";
|
|
|
|
repo = "ClickHouse";
|
|
|
|
rev = "v${version}-lts";
|
2020-07-07 16:57:20 +00:00
|
|
|
fetchSubmodules = true;
|
2023-06-13 08:47:02 +00:00
|
|
|
hash = "sha256-yeoL3HA1wRDg2+t3FtrM4wBtuu94Lpe4xxGxc09duQI=";
|
2023-06-05 21:39:51 +00:00
|
|
|
name = "clickhouse-${rev}.tar.gz";
|
|
|
|
postFetch = ''
|
|
|
|
# compress to not exceed the 4GB output limit
|
|
|
|
# try to make a deterministic tarball
|
|
|
|
tar -I 'gzip -n' \
|
|
|
|
--sort=name \
|
|
|
|
--mtime=1970-01-01 \
|
|
|
|
--owner=root --group=root \
|
|
|
|
--numeric-owner --mode=go=rX,u+rw,a-s \
|
|
|
|
--transform='s@^@source/@S' \
|
|
|
|
-cf temp -C "$out" .
|
|
|
|
rm -r "$out"
|
|
|
|
mv temp "$out"
|
|
|
|
'';
|
2017-03-27 01:06:23 +00:00
|
|
|
};
|
|
|
|
|
2023-04-21 20:40:09 +00:00
|
|
|
strictDeps = true;
|
|
|
|
nativeBuildInputs = [
|
|
|
|
cmake
|
|
|
|
ninja
|
|
|
|
python3
|
|
|
|
perl
|
|
|
|
] ++ lib.optionals stdenv.isx86_64 [
|
|
|
|
yasm
|
2023-05-18 12:41:03 +00:00
|
|
|
] ++ lib.optionals rustSupport [
|
|
|
|
rustc
|
|
|
|
cargo
|
|
|
|
rustPlatform.cargoSetupHook
|
2023-04-21 20:40:09 +00:00
|
|
|
];
|
2017-03-27 01:06:23 +00:00
|
|
|
|
2023-05-18 12:41:03 +00:00
|
|
|
corrosionDeps = if rustSupport then corrosion.cargoDeps else null;
|
|
|
|
blake3Deps = if rustSupport then rustPlatform.fetchCargoTarball {
|
|
|
|
inherit src;
|
|
|
|
name = "blake3-deps";
|
|
|
|
preBuild = "cd rust/BLAKE3";
|
|
|
|
hash = "sha256-lDMmmsyjEbTfI5NgTgT4+8QQrcUE/oUWfFgj1i19W0Q=";
|
|
|
|
} else null;
|
|
|
|
skimDeps = if rustSupport then rustPlatform.fetchCargoTarball {
|
|
|
|
inherit src;
|
|
|
|
name = "skim-deps";
|
|
|
|
preBuild = "cd rust/skim";
|
|
|
|
hash = "sha256-gEWB+U8QrM0yYyMXpwocszJZgOemdTlbSzKNkS0NbPk=";
|
|
|
|
} else null;
|
|
|
|
|
|
|
|
dontCargoSetupPostUnpack = true;
|
|
|
|
postUnpack = lib.optionalString rustSupport ''
|
|
|
|
pushd source
|
|
|
|
|
|
|
|
# their vendored version is too old and missing this patch: https://github.com/corrosion-rs/corrosion/pull/205
|
|
|
|
rm -rf contrib/corrosion
|
|
|
|
cp -r --no-preserve=mode ${corrosion.src} contrib/corrosion
|
|
|
|
|
|
|
|
pushd contrib/corrosion/generator
|
|
|
|
cargoDeps="$corrosionDeps" cargoSetupPostUnpackHook
|
|
|
|
corrosionDepsCopy="$cargoDepsCopy"
|
|
|
|
popd
|
|
|
|
|
|
|
|
pushd rust/BLAKE3
|
|
|
|
cargoDeps="$blake3Deps" cargoSetupPostUnpackHook
|
|
|
|
blake3DepsCopy="$cargoDepsCopy"
|
|
|
|
popd
|
|
|
|
|
|
|
|
pushd rust/skim
|
|
|
|
cargoDeps="$skimDeps" cargoSetupPostUnpackHook
|
|
|
|
skimDepsCopy="$cargoDepsCopy"
|
|
|
|
popd
|
|
|
|
|
|
|
|
popd
|
|
|
|
'';
|
|
|
|
|
2020-07-07 16:57:20 +00:00
|
|
|
postPatch = ''
|
|
|
|
patchShebangs src/
|
|
|
|
|
|
|
|
substituteInPlace src/Storages/System/StorageSystemLicenses.sh \
|
|
|
|
--replace 'git rev-parse --show-toplevel' '$src'
|
|
|
|
substituteInPlace utils/check-style/check-duplicate-includes.sh \
|
|
|
|
--replace 'git rev-parse --show-toplevel' '$src'
|
|
|
|
substituteInPlace utils/check-style/check-ungrouped-includes.sh \
|
|
|
|
--replace 'git rev-parse --show-toplevel' '$src'
|
|
|
|
substituteInPlace utils/list-licenses/list-licenses.sh \
|
|
|
|
--replace 'git rev-parse --show-toplevel' '$src'
|
|
|
|
substituteInPlace utils/check-style/check-style \
|
|
|
|
--replace 'git rev-parse --show-toplevel' '$src'
|
2023-05-18 12:41:03 +00:00
|
|
|
'' + lib.optionalString rustSupport ''
|
|
|
|
|
|
|
|
pushd contrib/corrosion/generator
|
|
|
|
cargoDepsCopy="$corrosionDepsCopy" cargoSetupPostPatchHook
|
|
|
|
popd
|
|
|
|
|
|
|
|
pushd rust/BLAKE3
|
|
|
|
cargoDepsCopy="$blake3DepsCopy" cargoSetupPostPatchHook
|
|
|
|
popd
|
|
|
|
|
|
|
|
pushd rust/skim
|
|
|
|
cargoDepsCopy="$skimDepsCopy" cargoSetupPostPatchHook
|
|
|
|
popd
|
|
|
|
|
|
|
|
cargoSetupPostPatchHook() { true; }
|
2020-07-07 16:57:20 +00:00
|
|
|
'';
|
|
|
|
|
2018-08-07 22:54:32 +00:00
|
|
|
cmakeFlags = [
|
|
|
|
"-DENABLE_TESTS=OFF"
|
2022-09-03 09:33:45 +00:00
|
|
|
"-DENABLE_CCACHE=0"
|
2020-12-05 12:45:15 +00:00
|
|
|
"-DENABLE_EMBEDDED_COMPILER=ON"
|
2023-04-21 20:40:09 +00:00
|
|
|
"-DWERROR=OFF"
|
2019-01-06 04:16:10 +00:00
|
|
|
];
|
|
|
|
|
2018-07-28 22:56:04 +00:00
|
|
|
postInstall = ''
|
|
|
|
rm -rf $out/share/clickhouse-test
|
2018-12-19 14:06:53 +00:00
|
|
|
|
|
|
|
sed -i -e '\!<log>/var/log/clickhouse-server/clickhouse-server\.log</log>!d' \
|
|
|
|
$out/etc/clickhouse-server/config.xml
|
|
|
|
substituteInPlace $out/etc/clickhouse-server/config.xml \
|
|
|
|
--replace "<errorlog>/var/log/clickhouse-server/clickhouse-server.err.log</errorlog>" "<console>1</console>"
|
2022-09-12 04:53:11 +00:00
|
|
|
substituteInPlace $out/etc/clickhouse-server/config.xml \
|
|
|
|
--replace "<level>trace</level>" "<level>warning</level>"
|
2018-07-28 22:56:04 +00:00
|
|
|
'';
|
|
|
|
|
2021-04-25 14:36:22 +00:00
|
|
|
# Builds in 7+h with 2 cores, and ~20m with a big-parallel builder.
|
|
|
|
requiredSystemFeatures = [ "big-parallel" ];
|
|
|
|
|
2021-11-21 19:38:57 +00:00
|
|
|
passthru.tests.clickhouse = nixosTests.clickhouse;
|
|
|
|
|
2021-01-11 07:54:33 +00:00
|
|
|
meta = with lib; {
|
2022-09-03 09:33:45 +00:00
|
|
|
homepage = "https://clickhouse.com";
|
2017-03-27 01:06:23 +00:00
|
|
|
description = "Column-oriented database management system";
|
|
|
|
license = licenses.asl20;
|
|
|
|
maintainers = with maintainers; [ orivej ];
|
2023-04-21 20:40:09 +00:00
|
|
|
|
|
|
|
# not supposed to work on 32-bit https://github.com/ClickHouse/ClickHouse/pull/23959#issuecomment-835343685
|
|
|
|
platforms = lib.filter (x: (lib.systems.elaborate x).is64bit) platforms.linux;
|
|
|
|
broken = stdenv.buildPlatform != stdenv.hostPlatform;
|
2017-03-27 01:06:23 +00:00
|
|
|
};
|
|
|
|
}
|