diff --git a/doc/release-notes/rl-2511.section.md b/doc/release-notes/rl-2511.section.md
index 80d07cc1095c..202ee003ead1 100644
--- a/doc/release-notes/rl-2511.section.md
+++ b/doc/release-notes/rl-2511.section.md
@@ -113,6 +113,10 @@
- `fetchgit`: Add `rootDir` argument to limit the resulting source to one subdirectory of the whole Git repository. Corresponding `--root-dir` option added to `nix-prefetch-git`.
+- The `clickhouse` package now track the stable upstream version per [upstream's
+ recommendation](https://clickhouse.com/docs/faq/operations/production). Users
+ can continue to use the `clickhouse-lts` package if desired.
+
## Nixpkgs Library {#sec-nixpkgs-release-25.11-lib}
diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix
index c26b1097823b..cb659e879878 100644
--- a/nixos/tests/all-tests.nix
+++ b/nixos/tests/all-tests.nix
@@ -333,7 +333,14 @@ in
cinnamon-wayland = runTest ./cinnamon-wayland.nix;
cjdns = runTest ./cjdns.nix;
clatd = runTest ./clatd.nix;
- clickhouse = import ./clickhouse { inherit runTest; };
+ clickhouse = import ./clickhouse {
+ inherit runTest;
+ package = pkgs.clickhouse;
+ };
+ clickhouse-lts = import ./clickhouse {
+ inherit runTest;
+ package = pkgs.clickhouse-lts;
+ };
cloud-init = runTest ./cloud-init.nix;
cloud-init-hostname = runTest ./cloud-init-hostname.nix;
cloudlog = runTest ./cloudlog.nix;
diff --git a/nixos/tests/clickhouse/base.nix b/nixos/tests/clickhouse/base.nix
index cbeb5b64699a..440492fdc987 100644
--- a/nixos/tests/clickhouse/base.nix
+++ b/nixos/tests/clickhouse/base.nix
@@ -1,10 +1,16 @@
-{ pkgs, ... }:
+{ pkgs, package, ... }:
{
name = "clickhouse";
- meta.maintainers = with pkgs.lib.maintainers; [ jpds ];
+ meta.maintainers = with pkgs.lib.maintainers; [
+ jpds
+ thevar1able
+ ];
nodes.machine = {
- services.clickhouse.enable = true;
+ services.clickhouse = {
+ enable = true;
+ inherit package;
+ };
virtualisation.memorySize = 4096;
};
diff --git a/nixos/tests/clickhouse/default.nix b/nixos/tests/clickhouse/default.nix
index e6568010eb66..88e01fcb1fdb 100644
--- a/nixos/tests/clickhouse/default.nix
+++ b/nixos/tests/clickhouse/default.nix
@@ -1,8 +1,31 @@
-{ runTest }:
+{
+ runTest,
+ package,
+}:
{
- base = runTest ./base.nix;
- kafka = runTest ./kafka.nix;
- keeper = runTest ./keeper.nix;
- s3 = runTest ./s3.nix;
+ base = runTest {
+ imports = [ ./base.nix ];
+ _module.args = {
+ inherit package;
+ };
+ };
+ kafka = runTest {
+ imports = [ ./kafka.nix ];
+ _module.args = {
+ inherit package;
+ };
+ };
+ keeper = runTest {
+ imports = [ ./keeper.nix ];
+ _module.args = {
+ inherit package;
+ };
+ };
+ s3 = runTest {
+ imports = [ ./s3.nix ];
+ _module.args = {
+ inherit package;
+ };
+ };
}
diff --git a/nixos/tests/clickhouse/kafka.nix b/nixos/tests/clickhouse/kafka.nix
index 29e4f839d07f..65dbd98be96f 100644
--- a/nixos/tests/clickhouse/kafka.nix
+++ b/nixos/tests/clickhouse/kafka.nix
@@ -1,4 +1,4 @@
-{ pkgs, ... }:
+{ pkgs, package, ... }:
let
kafkaNamedCollectionConfig = ''
@@ -28,7 +28,10 @@ let
in
{
name = "clickhouse-kafka";
- meta.maintainers = with pkgs.lib.maintainers; [ jpds ];
+ meta.maintainers = with pkgs.lib.maintainers; [
+ jpds
+ thevar1able
+ ];
nodes = {
clickhouse = {
@@ -38,7 +41,10 @@ in
};
};
- services.clickhouse.enable = true;
+ services.clickhouse = {
+ enable = true;
+ inherit package;
+ };
virtualisation.memorySize = 4096;
};
diff --git a/nixos/tests/clickhouse/keeper.nix b/nixos/tests/clickhouse/keeper.nix
index 40be4c19f2cf..49e9472e1375 100644
--- a/nixos/tests/clickhouse/keeper.nix
+++ b/nixos/tests/clickhouse/keeper.nix
@@ -1,7 +1,15 @@
-{ lib, pkgs, ... }:
+{
+ lib,
+ pkgs,
+ package,
+ ...
+}:
rec {
name = "clickhouse-keeper";
- meta.maintainers = with pkgs.lib.maintainers; [ jpds ];
+ meta.maintainers = with pkgs.lib.maintainers; [
+ jpds
+ thevar1able
+ ];
nodes =
let
@@ -94,7 +102,10 @@ rec {
9444
];
- services.clickhouse.enable = true;
+ services.clickhouse = {
+ enable = true;
+ inherit package;
+ };
systemd.services.clickhouse = {
after = [ "network-online.target" ];
diff --git a/nixos/tests/clickhouse/s3.nix b/nixos/tests/clickhouse/s3.nix
index 2268b6128fe6..20e4bf60bf8f 100644
--- a/nixos/tests/clickhouse/s3.nix
+++ b/nixos/tests/clickhouse/s3.nix
@@ -1,4 +1,4 @@
-{ pkgs, ... }:
+{ pkgs, package, ... }:
let
s3 = {
@@ -40,7 +40,10 @@ let
in
{
name = "clickhouse-s3";
- meta.maintainers = with pkgs.lib.maintainers; [ jpds ];
+ meta.maintainers = with pkgs.lib.maintainers; [
+ jpds
+ thevar1able
+ ];
nodes = {
clickhouse = {
@@ -50,7 +53,10 @@ in
};
};
- services.clickhouse.enable = true;
+ services.clickhouse = {
+ enable = true;
+ inherit package;
+ };
virtualisation.diskSize = 15 * 1024;
virtualisation.memorySize = 4 * 1024;
};
diff --git a/pkgs/by-name/cl/clickhouse/generic.nix b/pkgs/by-name/cl/clickhouse/generic.nix
new file mode 100644
index 000000000000..6ced512b876f
--- /dev/null
+++ b/pkgs/by-name/cl/clickhouse/generic.nix
@@ -0,0 +1,179 @@
+{
+ lts ? false,
+ version,
+ hash,
+ nixUpdateExtraArgs ? [ ],
+}:
+
+{
+ lib,
+ stdenv,
+ llvmPackages_19,
+ fetchFromGitHub,
+ cmake,
+ ninja,
+ python3,
+ perl,
+ nasm,
+ yasm,
+ nixosTests,
+ darwin,
+ findutils,
+ libiconv,
+ rustSupport ? true,
+ rustc,
+ cargo,
+ rustPlatform,
+ nix-update-script,
+}:
+
+llvmPackages_19.stdenv.mkDerivation (finalAttrs: {
+ pname = "clickhouse" + lib.optionalString lts "-lts";
+ inherit version;
+
+ src = fetchFromGitHub rec {
+ owner = "ClickHouse";
+ repo = "ClickHouse";
+ tag = "v${finalAttrs.version}";
+ fetchSubmodules = true;
+ name = "clickhouse-${tag}.tar.gz";
+ inherit hash;
+ postFetch = ''
+ # 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
+
+ # compress to not exceed the 2GB output limit
+ # try to make a deterministic tarball
+ tar -I 'gzip -n' \
+ --sort=name \
+ --mtime=1970-01-01 \
+ --owner=0 --group=0 \
+ --numeric-owner --mode=go=rX,u+rw,a-s \
+ --transform='s@^@source/@S' \
+ -cf temp -C "$out" .
+ rm -r "$out"
+ mv temp "$out"
+ '';
+ };
+
+ strictDeps = true;
+ nativeBuildInputs = [
+ cmake
+ ninja
+ python3
+ perl
+ llvmPackages_19.lld
+ ]
+ ++ lib.optionals stdenv.hostPlatform.isx86_64 [
+ nasm
+ yasm
+ ]
+ ++ lib.optionals stdenv.hostPlatform.isDarwin [
+ llvmPackages_19.bintools
+ findutils
+ darwin.bootstrap_cmds
+ ]
+ ++ lib.optionals rustSupport [
+ rustc
+ cargo
+ rustPlatform.cargoSetupHook
+ ];
+
+ buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [ libiconv ];
+
+ dontCargoSetupPostUnpack = true;
+
+ postPatch = ''
+ patchShebangs src/ utils/
+
+ sed -i 's|/usr/bin/env perl|"${lib.getExe perl}"|' contrib/openssl-cmake/CMakeLists.txt
+
+ substituteInPlace utils/list-licenses/list-licenses.sh \
+ --replace-fail '$(git rev-parse --show-toplevel)' "$NIX_BUILD_TOP/$sourceRoot"
+ ''
+ + lib.optionalString (lib.versions.majorMinor version <= "25.6") ''
+ substituteInPlace src/Storages/System/StorageSystemLicenses.sh \
+ --replace-fail '$(git rev-parse --show-toplevel)' "$NIX_BUILD_TOP/$sourceRoot"
+ ''
+ + lib.optionalString stdenv.hostPlatform.isDarwin ''
+ substituteInPlace cmake/tools.cmake \
+ --replace-fail 'gfind' 'find' \
+ --replace-fail 'ggrep' 'grep' \
+ --replace-fail '--ld-path=''${LLD_PATH}' '-fuse-ld=lld'
+ ''
+ # Rust is handled by cmake
+ + lib.optionalString rustSupport ''
+ cargoSetupPostPatchHook() { true; }
+ '';
+
+ cmakeFlags = [
+ "-DENABLE_CHDIG=OFF"
+ "-DENABLE_TESTS=OFF"
+ "-DENABLE_DELTA_KERNEL_RS=0"
+ "-DCOMPILER_CACHE=disabled"
+ ]
+ ++ lib.optional (
+ stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64
+ ) "-DNO_ARMV81_OR_HIGHER=1";
+
+ env = {
+ CARGO_HOME = "$PWD/../.cargo/";
+ NIX_CFLAGS_COMPILE =
+ # undefined reference to '__sync_val_compare_and_swap_16'
+ lib.optionalString stdenv.hostPlatform.isx86_64 " -mcx16"
+ +
+ # Silence ``-Wimplicit-const-int-float-conversion` error in MemoryTracker.cpp and
+ # ``-Wno-unneeded-internal-declaration` TreeOptimizer.cpp.
+ lib.optionalString stdenv.hostPlatform.isDarwin
+ " -Wno-implicit-const-int-float-conversion -Wno-unneeded-internal-declaration";
+ };
+
+ # https://github.com/ClickHouse/ClickHouse/issues/49988
+ hardeningDisable = [ "fortify" ];
+
+ postInstall = ''
+ sed -i -e '\!/var/log/clickhouse-server/clickhouse-server\.log!d' \
+ $out/etc/clickhouse-server/config.xml
+ substituteInPlace $out/etc/clickhouse-server/config.xml \
+ --replace-fail "/var/log/clickhouse-server/clickhouse-server.err.log" "1" \
+ --replace-fail "trace" "warning"
+ '';
+
+ # Basic smoke test
+ doCheck = true;
+ checkPhase = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
+ $NIX_BUILD_TOP/$sourceRoot/build/programs/clickhouse local --query 'SELECT 1' | grep 1
+ '';
+
+ # Builds in 7+h with 2 cores, and ~20m with a big-parallel builder.
+ requiredSystemFeatures = [ "big-parallel" ];
+
+ passthru = {
+ tests.clickhouse = if lts then nixosTests.clickhouse-lts else nixosTests.clickhouse;
+
+ updateScript = nix-update-script {
+ extraArgs = nixUpdateExtraArgs;
+ };
+ };
+
+ meta = with lib; {
+ homepage = "https://clickhouse.com";
+ description = "Column-oriented database management system";
+ license = licenses.asl20;
+ maintainers = with maintainers; [
+ orivej
+ mbalatsko
+ thevar1able
+ ];
+
+ # 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.darwin);
+ broken = stdenv.buildPlatform != stdenv.hostPlatform;
+ };
+})
diff --git a/pkgs/by-name/cl/clickhouse/lts.nix b/pkgs/by-name/cl/clickhouse/lts.nix
new file mode 100644
index 000000000000..58a48489078f
--- /dev/null
+++ b/pkgs/by-name/cl/clickhouse/lts.nix
@@ -0,0 +1,11 @@
+import ./generic.nix {
+ version = "25.3.6.56-lts";
+ hash = "sha256-wpC6uw811IWImLWAatYbghp3aZ+esEEBFng6AHIesK4=";
+ lts = true;
+ nixUpdateExtraArgs = [
+ "--version-regex"
+ "^v?(.*-lts)$"
+ "--override-filename"
+ "pkgs/by-name/cl/clickhouse/lts.nix"
+ ];
+}
diff --git a/pkgs/by-name/cl/clickhouse/package.nix b/pkgs/by-name/cl/clickhouse/package.nix
index e19aa2b51b95..ce7af6b9e7fc 100644
--- a/pkgs/by-name/cl/clickhouse/package.nix
+++ b/pkgs/by-name/cl/clickhouse/package.nix
@@ -1,169 +1,11 @@
-{
- lib,
- stdenv,
- llvmPackages_19,
- fetchFromGitHub,
- cmake,
- ninja,
- python3,
- perl,
- nasm,
- yasm,
- nixosTests,
- darwin,
- findutils,
- libiconv,
- rustSupport ? true,
- rustc,
- cargo,
- rustPlatform,
-}:
-
-llvmPackages_19.stdenv.mkDerivation (finalAttrs: {
- pname = "clickhouse";
- version = "25.3.5.42";
-
- src = fetchFromGitHub rec {
- owner = "ClickHouse";
- repo = "ClickHouse";
- tag = "v${finalAttrs.version}-lts";
- fetchSubmodules = true;
- name = "clickhouse-${tag}.tar.gz";
- hash = "sha256-LvGl9XJK6Emt7HnV/Orp7qEmJSr3TBJZtApL6GrWIMg=";
- postFetch = ''
- # 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
-
- # compress to not exceed the 2GB output limit
- # try to make a deterministic tarball
- tar -I 'gzip -n' \
- --sort=name \
- --mtime=1970-01-01 \
- --owner=0 --group=0 \
- --numeric-owner --mode=go=rX,u+rw,a-s \
- --transform='s@^@source/@S' \
- -cf temp -C "$out" .
- rm -r "$out"
- mv temp "$out"
- '';
- };
-
- strictDeps = true;
- nativeBuildInputs = [
- cmake
- ninja
- python3
- perl
- llvmPackages_19.lld
- ]
- ++ lib.optionals stdenv.hostPlatform.isx86_64 [
- nasm
- yasm
- ]
- ++ lib.optionals stdenv.hostPlatform.isDarwin [
- llvmPackages_19.bintools
- findutils
- darwin.bootstrap_cmds
- ]
- ++ lib.optionals rustSupport [
- rustc
- cargo
- rustPlatform.cargoSetupHook
+import ./generic.nix {
+ version = "25.7.4.11-stable";
+ hash = "sha256-SKDnnBdl9Rwc+ONH1chXAOFIwRmVG2l5cPEwpaDogzU=";
+ lts = false;
+ nixUpdateExtraArgs = [
+ "--version-regex"
+ "^v?(.*-stable)$"
+ "--override-filename"
+ "pkgs/by-name/cl/clickhouse/package.nix"
];
-
- buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [ libiconv ];
-
- dontCargoSetupPostUnpack = true;
-
- postPatch = ''
- patchShebangs src/
- patchShebangs utils/
-
- sed -i 's|/usr/bin/env perl|"${lib.getExe perl}"|' contrib/openssl-cmake/CMakeLists.txt
-
- substituteInPlace src/Storages/System/StorageSystemLicenses.sh \
- --replace-fail '$(git rev-parse --show-toplevel)' "$NIX_BUILD_TOP/$sourceRoot"
- substituteInPlace utils/check-style/check-ungrouped-includes.sh \
- --replace-fail '$(git rev-parse --show-toplevel)' "$NIX_BUILD_TOP/$sourceRoot"
- substituteInPlace utils/list-licenses/list-licenses.sh \
- --replace-fail '$(git rev-parse --show-toplevel)' "$NIX_BUILD_TOP/$sourceRoot"
- ''
- + lib.optionalString stdenv.hostPlatform.isDarwin ''
- sed -i 's|gfind|find|' cmake/tools.cmake
- sed -i 's|ggrep|grep|' cmake/tools.cmake
-
- # Make sure Darwin invokes lld.ld64 not lld.
- substituteInPlace cmake/tools.cmake \
- --replace '--ld-path=''${LLD_PATH}' '-fuse-ld=lld'
- ''
- + lib.optionalString rustSupport ''
- cargoSetupPostPatchHook() { true; }
- '';
-
- cmakeFlags = [
- "-DENABLE_TESTS=OFF"
- "-DENABLE_DELTA_KERNEL_RS=0"
- "-DCOMPILER_CACHE=disabled"
- ]
- ++ lib.optional (
- stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64
- ) "-DNO_ARMV81_OR_HIGHER=1";
-
- env = {
- CARGO_HOME = "$PWD/../.cargo/";
- NIX_CFLAGS_COMPILE =
- # undefined reference to '__sync_val_compare_and_swap_16'
- lib.optionalString stdenv.hostPlatform.isx86_64 " -mcx16"
- +
- # Silence ``-Wimplicit-const-int-float-conversion` error in MemoryTracker.cpp and
- # ``-Wno-unneeded-internal-declaration` TreeOptimizer.cpp.
- lib.optionalString stdenv.hostPlatform.isDarwin
- " -Wno-implicit-const-int-float-conversion -Wno-unneeded-internal-declaration";
- };
-
- # https://github.com/ClickHouse/ClickHouse/issues/49988
- hardeningDisable = [ "fortify" ];
-
- postInstall = ''
- rm -rf $out/share/clickhouse-test
-
- sed -i -e '\!/var/log/clickhouse-server/clickhouse-server\.log!d' \
- $out/etc/clickhouse-server/config.xml
- substituteInPlace $out/etc/clickhouse-server/config.xml \
- --replace-fail "/var/log/clickhouse-server/clickhouse-server.err.log" "1"
- substituteInPlace $out/etc/clickhouse-server/config.xml \
- --replace-fail "trace" "warning"
- '';
-
- # Basic smoke test
- doCheck = true;
- checkPhase = ''
- $NIX_BUILD_TOP/$sourceRoot/build/programs/clickhouse local --query 'SELECT 1' | grep 1
- '';
-
- # Builds in 7+h with 2 cores, and ~20m with a big-parallel builder.
- requiredSystemFeatures = [ "big-parallel" ];
-
- passthru.tests.clickhouse = nixosTests.clickhouse;
-
- meta = with lib; {
- homepage = "https://clickhouse.com";
- description = "Column-oriented database management system";
- license = licenses.asl20;
- maintainers = with maintainers; [
- orivej
- mbalatsko
- thevar1able
- ];
-
- # 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.darwin);
- broken = stdenv.buildPlatform != stdenv.hostPlatform;
- };
-})
+}
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 82f13ae44c9a..3558734ca83d 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -2637,6 +2637,8 @@ with pkgs;
ckb-next = libsForQt5.callPackage ../tools/misc/ckb-next { };
+ clickhouse-lts = callPackage ../by-name/cl/clickhouse/lts.nix { };
+
cmdpack = callPackages ../tools/misc/cmdpack { };
cocoapods = callPackage ../development/tools/cocoapods { };