summary refs log tree commit diff
diff options
context:
space:
mode:
authorDomen Kožar <domen@dev.si>2023-06-20 20:38:33 +0100
committerGitHub <noreply@github.com>2023-06-20 20:38:33 +0100
commit34038fa36a74ad98f1531e4136d6d9981e6fe6b0 (patch)
treec641cb4f56650474e25d09daca81a5666383499d
parentfd6b1b92bda3fe445ebc191e1d8b61cafc58e6cc (diff)
parentd13769fd8e4a22bc302c37e428ea25959b8ceba9 (diff)
downloadnixpkgs-34038fa36a74ad98f1531e4136d6d9981e6fe6b0.tar
nixpkgs-34038fa36a74ad98f1531e4136d6d9981e6fe6b0.tar.gz
nixpkgs-34038fa36a74ad98f1531e4136d6d9981e6fe6b0.tar.bz2
nixpkgs-34038fa36a74ad98f1531e4136d6d9981e6fe6b0.tar.lz
nixpkgs-34038fa36a74ad98f1531e4136d6d9981e6fe6b0.tar.xz
nixpkgs-34038fa36a74ad98f1531e4136d6d9981e6fe6b0.tar.zst
nixpkgs-34038fa36a74ad98f1531e4136d6d9981e6fe6b0.zip
Merge pull request #237401 from domenkozar/clickhouse-darwin
clickhouse: build on darwin
-rw-r--r--pkgs/servers/clickhouse/default.nix45
-rw-r--r--pkgs/top-level/all-packages.nix2
2 files changed, 29 insertions, 18 deletions
diff --git a/pkgs/servers/clickhouse/default.nix b/pkgs/servers/clickhouse/default.nix
index 92955d9d8e9..12d2b322830 100644
--- a/pkgs/servers/clickhouse/default.nix
+++ b/pkgs/servers/clickhouse/default.nix
@@ -1,5 +1,5 @@
 { 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;
   };
 }
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 7d4e01917f7..a4b3de37806 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -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;