From e5d6f9e329e32280dc0a57e659b84e9c32a59506 Mon Sep 17 00:00:00 2001 From: "R. RyanTM" Date: Sun, 16 Dec 2018 03:11:18 -0800 Subject: [PATCH 1/2] clickhouse: 18.14.9 -> 18.14.18 Semi-automatic update generated by https://github.com/ryantm/nixpkgs-update tools. This update was made based on information from https://repology.org/metapackage/clickhouse/versions --- pkgs/servers/clickhouse/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/servers/clickhouse/default.nix b/pkgs/servers/clickhouse/default.nix index 88907231d6e..b53c6388d18 100644 --- a/pkgs/servers/clickhouse/default.nix +++ b/pkgs/servers/clickhouse/default.nix @@ -6,13 +6,13 @@ stdenv.mkDerivation rec { name = "clickhouse-${version}"; - version = "18.14.9"; + version = "18.14.18"; src = fetchFromGitHub { owner = "yandex"; repo = "ClickHouse"; rev = "v${version}-stable"; - sha256 = "1dsqwihh48fgsjy3jmfjk5271dw3052agw5wpfdm054nkkych86i"; + sha256 = "0nivnmlnamcjxwc66ja9fagi5fqzzjsnrrfk32f4g8sxffx2rjy3"; }; nativeBuildInputs = [ cmake libtool ninja ]; From 64d05bbdd2a745885f195b4f54fc518b07b9db7c Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Wed, 19 Dec 2018 15:06:53 +0100 Subject: [PATCH 2/2] clickhouse: fix module and package runtime Although the package itself builds fine, the module fails because it tries to log into a non-existant file in `/var/log` which breaks the service. Patching to default config to log to stdout by default fixes the issue. Additionally this is the better solution as NixOS heavily relies on systemd (and thus journald) for logging. Also, the runtime relies on `/etc/localtime` to start, as it's not required by the module system we set UTC as sensitive default when using the module. To ensure that the service's basic functionality is available, a simple NixOS test has been added. --- .../modules/services/databases/clickhouse.nix | 5 ++++ nixos/tests/all-tests.nix | 1 + nixos/tests/clickhouse.nix | 25 +++++++++++++++++++ pkgs/servers/clickhouse/default.nix | 5 ++++ 4 files changed, 36 insertions(+) create mode 100644 nixos/tests/clickhouse.nix diff --git a/nixos/modules/services/databases/clickhouse.nix b/nixos/modules/services/databases/clickhouse.nix index 1b8771cec39..21e0cee3415 100644 --- a/nixos/modules/services/databases/clickhouse.nix +++ b/nixos/modules/services/databases/clickhouse.nix @@ -70,6 +70,11 @@ with lib; }; }; + environment.systemPackages = [ pkgs.clickhouse ]; + + # startup requires a `/etc/localtime` which only if exists if `time.timeZone != null` + time.timeZone = mkDefault "UTC"; + }; } diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index ca5015ded3e..1e8e2213fac 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -39,6 +39,7 @@ in cfssl = handleTestOn ["x86_64-linux"] ./cfssl.nix {}; chromium = (handleTestOn ["x86_64-linux"] ./chromium.nix {}).stable or {}; cjdns = handleTest ./cjdns.nix {}; + clickhouse = handleTest ./clickhouse.nix {}; cloud-init = handleTest ./cloud-init.nix {}; codimd = handleTest ./codimd.nix {}; containers-bridge = handleTest ./containers-bridge.nix {}; diff --git a/nixos/tests/clickhouse.nix b/nixos/tests/clickhouse.nix new file mode 100644 index 00000000000..7d835069ec4 --- /dev/null +++ b/nixos/tests/clickhouse.nix @@ -0,0 +1,25 @@ +import ./make-test.nix ({ pkgs, ... }: { + name = "clickhouse"; + meta.maintainers = with pkgs.stdenv.lib.maintainers; [ ma27 ]; + + machine = { + services.clickhouse.enable = true; + }; + + testScript = + let + # work around quote/substitution complexity by Nix, Perl, bash and SQL. + tableDDL = pkgs.writeText "ddl.sql" "CREATE TABLE `demo` (`value` FixedString(10)) engine = MergeTree PARTITION BY value ORDER BY tuple();"; + insertQuery = pkgs.writeText "insert.sql" "INSERT INTO `demo` (`value`) VALUES ('foo');"; + selectQuery = pkgs.writeText "select.sql" "SELECT * from `demo`"; + in + '' + $machine->start(); + $machine->waitForUnit("clickhouse.service"); + $machine->waitForOpenPort(9000); + + $machine->succeed("cat ${tableDDL} | clickhouse-client"); + $machine->succeed("cat ${insertQuery} | clickhouse-client"); + $machine->succeed("cat ${selectQuery} | clickhouse-client | grep foo"); + ''; +}) diff --git a/pkgs/servers/clickhouse/default.nix b/pkgs/servers/clickhouse/default.nix index b53c6388d18..bddffc52fd7 100644 --- a/pkgs/servers/clickhouse/default.nix +++ b/pkgs/servers/clickhouse/default.nix @@ -36,6 +36,11 @@ stdenv.mkDerivation rec { 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 "/var/log/clickhouse-server/clickhouse-server.err.log" "1" ''; meta = with stdenv.lib; {