From 8f634a78b95dc441317e5bf581da8b803d0863b2 Mon Sep 17 00:00:00 2001 From: Orivej Desh Date: Mon, 27 Mar 2017 01:06:23 +0000 Subject: [PATCH] clickhouse: init at 1.1.54190 --- nixos/modules/misc/ids.nix | 2 + nixos/modules/module-list.nix | 1 + .../modules/services/databases/clickhouse.nix | 75 +++++++++++++++++++ pkgs/servers/clickhouse/default.nix | 34 +++++++++ pkgs/servers/clickhouse/prefix.patch | 30 ++++++++ pkgs/servers/clickhouse/termcap.patch | 25 +++++++ pkgs/top-level/all-packages.nix | 2 + 7 files changed, 169 insertions(+) create mode 100644 nixos/modules/services/databases/clickhouse.nix create mode 100644 pkgs/servers/clickhouse/default.nix create mode 100644 pkgs/servers/clickhouse/prefix.patch create mode 100644 pkgs/servers/clickhouse/termcap.patch diff --git a/nixos/modules/misc/ids.nix b/nixos/modules/misc/ids.nix index 4232f57cb6b..e609d100851 100644 --- a/nixos/modules/misc/ids.nix +++ b/nixos/modules/misc/ids.nix @@ -292,6 +292,7 @@ sonarr = 274; radarr = 275; jackett = 276; + clickhouse = 277; # When adding a uid, make sure it doesn't match an existing gid. And don't use uids above 399! @@ -553,6 +554,7 @@ sonarr = 274; radarr = 275; jackett = 276; + clickhouse = 277; # When adding a gid, make sure it doesn't match an existing # uid. Users and groups with the same name should have equal diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 4ff069f48ab..12ca21f4c2c 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -163,6 +163,7 @@ ./services/continuous-integration/jenkins/slave.nix ./services/databases/4store-endpoint.nix ./services/databases/4store.nix + ./services/databases/clickhouse.nix ./services/databases/couchdb.nix ./services/databases/firebird.nix ./services/databases/hbase.nix diff --git a/nixos/modules/services/databases/clickhouse.nix b/nixos/modules/services/databases/clickhouse.nix new file mode 100644 index 00000000000..631d7f8cba7 --- /dev/null +++ b/nixos/modules/services/databases/clickhouse.nix @@ -0,0 +1,75 @@ +{ config, lib, pkgs, ... }: +let + cfg = config.services.clickhouse; + confDir = "/etc/clickhouse-server"; + stateDir = "/var/lib/clickhouse"; +in +with lib; +{ + + ###### interface + + options = { + + services.clickhouse = { + + enable = mkOption { + default = false; + description = "Whether to enable ClickHouse database server."; + }; + + }; + + }; + + + ###### implementation + + config = mkIf cfg.enable { + + users.extraUsers.clickhouse = { + name = "clickhouse"; + uid = config.ids.uids.clickhouse; + group = "clickhouse"; + description = "ClickHouse server user"; + }; + + users.extraGroups.clickhouse.gid = config.ids.gids.clickhouse; + + systemd.services.clickhouse = { + description = "ClickHouse server"; + + wantedBy = [ "multi-user.target" ]; + + after = [ "network.target" ]; + + preStart = '' + mkdir -p ${stateDir} + chown clickhouse:clickhouse ${confDir} ${stateDir} + ''; + + script = '' + cd "${confDir}" + exec ${pkgs.clickhouse}/bin/clickhouse-server + ''; + + serviceConfig = { + User = "clickhouse"; + Group = "clickhouse"; + PermissionsStartOnly = true; + }; + }; + + environment.etc = { + "clickhouse-server/config.xml" = { + source = "${pkgs.clickhouse}/etc/clickhouse-server/config.xml"; + }; + + "clickhouse-server/users.xml" = { + source = "${pkgs.clickhouse}/etc/clickhouse-server/users.xml"; + }; + }; + + }; + +} diff --git a/pkgs/servers/clickhouse/default.nix b/pkgs/servers/clickhouse/default.nix new file mode 100644 index 00000000000..fc35dfdda47 --- /dev/null +++ b/pkgs/servers/clickhouse/default.nix @@ -0,0 +1,34 @@ +{ stdenv, fetchFromGitHub, cmake, libtool, boost, double_conversion, gperftools, icu, libmysql, lz4, openssl, poco, re2, readline, sparsehash, unixODBC, zookeeper_mt, zstd }: + +stdenv.mkDerivation rec { + name = "clickhouse-${version}"; + + version = "1.1.54190"; + + src = fetchFromGitHub { + owner = "yandex"; + repo = "ClickHouse"; + rev = "v${version}-stable"; + sha256 = "03snzrhz3ai66fqy3rh89cgmpiaskg3077zflkwzqxwx69jkmqix"; + }; + + patches = [ ./prefix.patch ./termcap.patch ]; + + nativeBuildInputs = [ cmake libtool ]; + + buildInputs = [ boost double_conversion gperftools icu libmysql lz4 openssl poco re2 readline sparsehash unixODBC zookeeper_mt zstd ]; + + cmakeFlags = [ "-DENABLE_TESTS=OFF" "-DUNBUNDLED=ON" "-DUSE_STATIC_LIBRARIES=OFF" ]; + + NIX_CFLAGS_COMPILE = [ "-Wno-error=unused-function" ]; + + enableParallelBuilding = true; + + meta = with stdenv.lib; { + homepage = https://clickhouse.yandex/; + description = "Column-oriented database management system"; + license = licenses.asl20; + maintainers = with maintainers; [ orivej ]; + platforms = platforms.linux; + }; +} diff --git a/pkgs/servers/clickhouse/prefix.patch b/pkgs/servers/clickhouse/prefix.patch new file mode 100644 index 00000000000..a311bf83dd9 --- /dev/null +++ b/pkgs/servers/clickhouse/prefix.patch @@ -0,0 +1,30 @@ +From ccc3596aa3ca041f457bf44d3437d935f56e82a4 Mon Sep 17 00:00:00 2001 +From: Orivej Desh +Date: Sun, 26 Mar 2017 23:57:32 +0000 +Subject: [PATCH] Do not override CMAKE_INSTALL_PREFIX + +--- + CMakeLists.txt | 7 +------ + 1 file changed, 1 insertion(+), 6 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 517b25e..6d8ced2 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -141,12 +141,7 @@ if (ENABLE_TESTS) + endif (ENABLE_TESTS) + + # Installation prefix +-if (NOT CMAKE_SYSTEM MATCHES "FreeBSD") +- set (CMAKE_INSTALL_PREFIX /usr) +- set (CLICKHOUSE_ETC_DIR /etc) +-else () +- set (CLICKHOUSE_ETC_DIR ${CMAKE_INSTALL_PREFIX}/etc) +-endif () ++set (CLICKHOUSE_ETC_DIR ${CMAKE_INSTALL_PREFIX}/etc) + + + option (UNBUNDLED "Try find all libraries in system (if fail - use bundled from contrib/)" OFF) +-- +2.12.0 + diff --git a/pkgs/servers/clickhouse/termcap.patch b/pkgs/servers/clickhouse/termcap.patch new file mode 100644 index 00000000000..e030d095690 --- /dev/null +++ b/pkgs/servers/clickhouse/termcap.patch @@ -0,0 +1,25 @@ +From c2105ecdf6a6cc1fbb4c1ae01475db6a65fee32f Mon Sep 17 00:00:00 2001 +From: Orivej Desh +Date: Mon, 27 Mar 2017 01:39:11 +0000 +Subject: [PATCH] Search for termcap in ncurses + +--- + cmake/find_readline_edit.cmake | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/cmake/find_readline_edit.cmake b/cmake/find_readline_edit.cmake +index 26f2768..f520ece 100644 +--- a/cmake/find_readline_edit.cmake ++++ b/cmake/find_readline_edit.cmake +@@ -7,7 +7,7 @@ endif () + + list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES .so.2) + +-find_library (TERMCAP_LIB NAMES termcap) ++find_library (TERMCAP_LIB NAMES ncurses) + find_library (EDIT_LIB NAMES edit) + + set(READLINE_INCLUDE_PATHS "/var/empty/local/var/empty/readline/include") +-- +2.12.0 + diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 3be611430f6..33d622d9f52 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -10649,6 +10649,8 @@ with pkgs; charybdis = callPackage ../servers/irc/charybdis {}; + clickhouse = callPackage ../servers/clickhouse { }; + couchdb = callPackage ../servers/http/couchdb { spidermonkey = spidermonkey_1_8_5; python = python27;