Unverified Commit 34038fa3 authored by Domen Kožar's avatar Domen Kožar Committed by GitHub
Browse files

Merge pull request #237401 from domenkozar/clickhouse-darwin

clickhouse: build on darwin
parents fd6b1b92 d13769fd
Loading
Loading
Loading
Loading
+28 −17
Original line number Diff line number Diff line
{ lib
, stdenv
, llvmPackages
, fetchFromGitHub
, cmake
, ninja
@@ -7,6 +7,8 @@
, perl
, yasm
, nixosTests
, darwin
, findutils

# currently for BLAKE3 hash function
, rustSupport ? true
@@ -17,7 +19,13 @@
, rustPlatform
}:

stdenv.mkDerivation rec {
let
  inherit (llvmPackages) stdenv;
  mkDerivation = (
    if stdenv.isDarwin
    then darwin.apple_sdk_11_0.llvmPackages_15.stdenv
    else llvmPackages.stdenv).mkDerivation;
in mkDerivation rec {
  pname = "clickhouse";
  version = "23.3.3.52";

@@ -26,20 +34,16 @@ stdenv.mkDerivation rec {
    repo = "ClickHouse";
    rev = "v${version}-lts";
    fetchSubmodules = true;
    hash = "sha256-yeoL3HA1wRDg2+t3FtrM4wBtuu94Lpe4xxGxc09duQI=";
    name = "clickhouse-${rev}.tar.gz";
    hash = "sha256-fVwwMj0WbyCbe4WfpYMGVM6vXFgHsjg9MUZbNyd+a/w=";
    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"
      # delete files that make the source too big
      rm -rf $out/contrib/llvm-project/llvm/test
      rm -rf $out/contrib/llvm-project/clang/test
      rm -rf $out/contrib/croaring/benchmarks

      # fix case insensitivity on macos https://github.com/NixOS/nixpkgs/issues/39308
      rm -rf $out/contrib/sysroot/linux-*
      rm -rf $out/contrib/liburing/man
    '';
  };

@@ -51,6 +55,10 @@ stdenv.mkDerivation rec {
    perl
  ] ++ lib.optionals stdenv.isx86_64 [
    yasm
  ] ++ lib.optionals stdenv.isDarwin [
    llvmPackages.bintools
    findutils
    darwin.bootstrap_cmds
  ] ++ lib.optionals rustSupport [
    rustc
    cargo
@@ -110,6 +118,9 @@ stdenv.mkDerivation rec {
      --replace 'git rev-parse --show-toplevel' '$src'
    substituteInPlace utils/check-style/check-style \
      --replace 'git rev-parse --show-toplevel' '$src'
  '' + lib.optionalString stdenv.isDarwin ''
    sed -i 's|gfind|find|' cmake/tools.cmake
    sed -i 's|ggrep|grep|' cmake/tools.cmake
  '' + lib.optionalString rustSupport ''

    pushd contrib/corrosion/generator
@@ -129,7 +140,7 @@ stdenv.mkDerivation rec {

  cmakeFlags = [
    "-DENABLE_TESTS=OFF"
    "-DENABLE_CCACHE=0"
    "-DCOMPILER_CACHE=disabled"
    "-DENABLE_EMBEDDED_COMPILER=ON"
    "-DWERROR=OFF"
  ];
@@ -157,7 +168,7 @@ stdenv.mkDerivation rec {
    maintainers = with maintainers; [ orivej ];

    # 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;
    platforms = lib.filter (x: (lib.systems.elaborate x).is64bit) (platforms.linux ++ platforms.darwin);
    broken = stdenv.buildPlatform != stdenv.hostPlatform;
  };
}
+1 −1
Original line number Diff line number Diff line
@@ -25494,7 +25494,7 @@ with pkgs;
  clamsmtp = callPackage ../servers/mail/clamsmtp { };
  clickhouse = callPackage ../servers/clickhouse {
    stdenv = llvmPackages_15.stdenv;
    llvmPackages = llvmPackages_15;
  };
  clickhouse-cli = with python3Packages; toPythonApplication clickhouse-cli;