From 6b1278e8ba8a01c83ac67ea4203879111c6be98a Mon Sep 17 00:00:00 2001 From: shivaraj-bh Date: Fri, 5 Jul 2024 23:11:48 +0530 Subject: [PATCH 1/2] refactor: Do not repeat `dataDir` chore: Elaborate description for `dataDir` Co-authored-by: Sridhar Ratnakumar <3998+srid@users.noreply.github.com> --- nix/apache-kafka.nix | 6 ------ nix/cassandra.nix | 6 ------ nix/clickhouse/default.nix | 6 ------ nix/elasticsearch.nix | 6 ------ nix/grafana.nix | 6 ------ nix/lib.nix | 5 +++++ nix/mysql/default.nix | 6 ------ nix/nginx/default.nix | 6 ------ nix/ollama.nix | 9 +-------- nix/open-webui.nix | 6 ------ nix/pgadmin.nix | 6 ------ nix/postgres/default.nix | 6 ------ nix/prometheus.nix | 6 ------ nix/redis-cluster.nix | 6 ------ nix/redis.nix | 6 ------ nix/tempo.nix | 6 ------ nix/weaviate.nix | 6 ------ nix/zookeeper.nix | 8 -------- 18 files changed, 6 insertions(+), 106 deletions(-) diff --git a/nix/apache-kafka.nix b/nix/apache-kafka.nix index bca66901..64196ad8 100644 --- a/nix/apache-kafka.nix +++ b/nix/apache-kafka.nix @@ -28,12 +28,6 @@ with lib; type = types.port; }; - dataDir = lib.mkOption { - type = types.str; - default = "./data/${name}"; - description = lib.mdDoc "The apache-kafka data directory"; - }; - settings = mkOption { description = lib.mdDoc '' [Kafka broker configuration](https://kafka.apache.org/documentation.html#brokerconfigs) diff --git a/nix/cassandra.nix b/nix/cassandra.nix index afa7b0c3..4d8f9fa2 100644 --- a/nix/cassandra.nix +++ b/nix/cassandra.nix @@ -10,12 +10,6 @@ in package = lib.mkPackageOption pkgs "cassandra" { }; - dataDir = lib.mkOption { - type = types.str; - default = "./data/${name}"; - description = "The cassandra data directory"; - }; - listenAddress = lib.mkOption { type = types.str; description = "Listen address"; diff --git a/nix/clickhouse/default.nix b/nix/clickhouse/default.nix index 29589cb0..735ce971 100644 --- a/nix/clickhouse/default.nix +++ b/nix/clickhouse/default.nix @@ -21,12 +21,6 @@ in default = 9000; }; - dataDir = lib.mkOption { - type = types.str; - default = "./data/${name}"; - description = "The clickhouse data directory"; - }; - defaultExtraConfig = lib.mkOption { type = yamlFormat.type; internal = true; diff --git a/nix/elasticsearch.nix b/nix/elasticsearch.nix index bb215b75..4af27d55 100644 --- a/nix/elasticsearch.nix +++ b/nix/elasticsearch.nix @@ -21,12 +21,6 @@ in package = lib.mkPackageOption pkgs "elasticsearch7" { }; - dataDir = lib.mkOption { - type = types.str; - default = "./data/${name}"; - description = "Directory where elasticsearch stores its data."; - }; - listenAddress = lib.mkOption { description = "Elasticsearch listen address."; default = "127.0.0.1"; diff --git a/nix/grafana.nix b/nix/grafana.nix index 29ab6cdc..2e000c7b 100644 --- a/nix/grafana.nix +++ b/nix/grafana.nix @@ -31,12 +31,6 @@ in default = "http"; }; - dataDir = lib.mkOption { - type = types.str; - description = "Directory where grafana stores its logs and data."; - default = "./data/${name}"; - }; - extraConf = lib.mkOption { type = iniFormat.type; description = "Extra configuration for grafana."; diff --git a/nix/lib.nix b/nix/lib.nix index 554ac9ca..e02ef0c2 100644 --- a/nix/lib.nix +++ b/nix/lib.nix @@ -15,6 +15,11 @@ ]; serviceModule = { config, name, ... }: { options = { + dataDir = lib.mkOption { + type = lib.types.str; + default = "./data/${name}"; + description = "The directory where all data for `${service}.` is stored"; + }; namespace = lib.mkOption { description = '' Namespace for the ${service} service diff --git a/nix/mysql/default.nix b/nix/mysql/default.nix index e4bf1276..22282cad 100644 --- a/nix/mysql/default.nix +++ b/nix/mysql/default.nix @@ -15,12 +15,6 @@ in defaultText = lib.literalExpression "pkgs.mariadb"; }; - dataDir = lib.mkOption { - type = types.str; - default = "./data/${name}"; - description = "The mysql data directory"; - }; - socketDir = lib.mkOption { type = types.nullOr types.str; default = config.dataDir; diff --git a/nix/nginx/default.nix b/nix/nginx/default.nix index 4ad3b15a..1d5d81af 100644 --- a/nix/nginx/default.nix +++ b/nix/nginx/default.nix @@ -41,12 +41,6 @@ in description = "The nginx package to use."; }; - dataDir = lib.mkOption { - type = types.str; - default = "./data/${name}"; - description = "The nginx data directory"; - }; - port = lib.mkOption { type = types.port; default = 8080; diff --git a/nix/ollama.nix b/nix/ollama.nix index a4689276..7d89b176 100644 --- a/nix/ollama.nix +++ b/nix/ollama.nix @@ -25,14 +25,7 @@ in example = "0.0.0.0"; description = "The host on which the Ollama service's REST API will listen"; }; - dataDir = lib.mkOption { - type = types.str; - default = "./data/${name}"; - description = '' - The directory containing the Ollama models. - Sets the `OLLAMA_MODELS` environment variable. - ''; - }; + keepAlive = lib.mkOption { type = types.str; default = "5m"; diff --git a/nix/open-webui.nix b/nix/open-webui.nix index 4fba54dd..b80be571 100644 --- a/nix/open-webui.nix +++ b/nix/open-webui.nix @@ -8,12 +8,6 @@ in enable = lib.mkEnableOption "Open-WebUI server"; package = lib.mkPackageOption pkgs "open-webui" { }; - dataDir = lib.mkOption { - type = types.str; - default = "./data/${name}"; - description = "The Open-WebUI data directory"; - }; - host = lib.mkOption { type = types.str; default = "127.0.0.1"; diff --git a/nix/pgadmin.nix b/nix/pgadmin.nix index 009aa62a..a47caab4 100644 --- a/nix/pgadmin.nix +++ b/nix/pgadmin.nix @@ -58,12 +58,6 @@ in default = 6; }; - dataDir = lib.mkOption { - type = types.str; - default = "./data/${name}"; - description = "The pgadmin4 data directory"; - }; - extraDefaultConfig = lib.mkOption { type = pyType; internal = true; diff --git a/nix/postgres/default.nix b/nix/postgres/default.nix index 5358da76..7b750f04 100644 --- a/nix/postgres/default.nix +++ b/nix/postgres/default.nix @@ -44,12 +44,6 @@ in ''; }; - dataDir = lib.mkOption { - type = lib.types.str; - default = "./data/${name}"; - description = "The DB data directory"; - }; - socketDir = lib.mkOption { type = lib.types.str; default = ""; diff --git a/nix/prometheus.nix b/nix/prometheus.nix index 6714bd80..45d6a5b7 100644 --- a/nix/prometheus.nix +++ b/nix/prometheus.nix @@ -21,12 +21,6 @@ in description = lib.mdDoc "Address to listen on for the web interface, API, and telemetry"; }; - dataDir = lib.mkOption { - type = types.str; - default = "./data/${name}"; - description = "The prometheus data directory"; - }; - extraFlags = lib.mkOption { type = types.listOf types.str; default = [ ]; diff --git a/nix/redis-cluster.nix b/nix/redis-cluster.nix index f72eeb6c..af210e3d 100644 --- a/nix/redis-cluster.nix +++ b/nix/redis-cluster.nix @@ -8,12 +8,6 @@ in package = lib.mkPackageOption pkgs "redis" { }; - dataDir = lib.mkOption { - type = types.str; - default = "./data/${name}"; - description = "The redis-cluster data directory (common for all nodes)."; - }; - nodes = lib.mkOption { type = types.attrsOf (types.submodule { options = { diff --git a/nix/redis.nix b/nix/redis.nix index 8c36a620..c8f4c934 100644 --- a/nix/redis.nix +++ b/nix/redis.nix @@ -9,12 +9,6 @@ in package = lib.mkPackageOption pkgs "redis" { }; - dataDir = lib.mkOption { - type = types.str; - default = "./data/${name}"; - description = "The redis data directory"; - }; - bind = lib.mkOption { type = types.nullOr types.str; default = "127.0.0.1"; diff --git a/nix/tempo.nix b/nix/tempo.nix index 4a7def01..b2d85151 100644 --- a/nix/tempo.nix +++ b/nix/tempo.nix @@ -24,12 +24,6 @@ in default = 3200; }; - dataDir = lib.mkOption { - type = types.str; - default = "./data/${name}"; - description = "The tempo data directory"; - }; - extraConfig = lib.mkOption { type = yamlFormat.type; default = { }; diff --git a/nix/weaviate.nix b/nix/weaviate.nix index d6c263ad..dd305028 100644 --- a/nix/weaviate.nix +++ b/nix/weaviate.nix @@ -12,12 +12,6 @@ in package = lib.mkPackageOption pkgs "weaviate" { }; - dataDir = lib.mkOption { - type = types.str; - default = "./data/${name}"; - description = "Path to the Weaviate data store"; - }; - host = lib.mkOption { type = types.str; default = "127.0.0.1"; diff --git a/nix/zookeeper.nix b/nix/zookeeper.nix index 846f7380..b6ae604b 100644 --- a/nix/zookeeper.nix +++ b/nix/zookeeper.nix @@ -12,14 +12,6 @@ with lib; type = types.port; }; - dataDir = mkOption { - type = types.str; - default = "./data/${name}"; - description = lib.mdDoc '' - Data directory for Zookeeper - ''; - }; - id = mkOption { description = lib.mdDoc "Zookeeper ID."; default = 0; From f99c5a127fe2e38a042dc0ce17940a360cdf0e39 Mon Sep 17 00:00:00 2001 From: shivaraj-bh Date: Fri, 5 Jul 2024 23:30:15 +0530 Subject: [PATCH 2/2] refactor: Do not repeat `enable` option --- nix/apache-kafka.nix | 2 -- nix/cassandra.nix | 2 -- nix/clickhouse/default.nix | 2 -- nix/elasticsearch.nix | 2 -- nix/grafana.nix | 2 -- nix/lib.nix | 1 + nix/mysql/default.nix | 2 -- nix/nginx/default.nix | 2 -- nix/ollama.nix | 1 - nix/open-webui.nix | 1 - nix/pgadmin.nix | 2 -- nix/postgres/default.nix | 2 -- nix/prometheus.nix | 2 -- nix/redis-cluster.nix | 2 -- nix/redis.nix | 2 -- nix/searxng.nix | 1 - nix/tempo.nix | 2 -- nix/weaviate.nix | 2 -- nix/zookeeper.nix | 2 -- 19 files changed, 1 insertion(+), 33 deletions(-) diff --git a/nix/apache-kafka.nix b/nix/apache-kafka.nix index 64196ad8..53c51fd1 100644 --- a/nix/apache-kafka.nix +++ b/nix/apache-kafka.nix @@ -20,8 +20,6 @@ in with lib; { options = { - enable = mkEnableOption (lib.mdDoc "Apache Kafka event streaming broker"); - port = mkOption { description = lib.mdDoc "Port number the broker should listen on."; default = 9092; diff --git a/nix/cassandra.nix b/nix/cassandra.nix index 4d8f9fa2..bc194990 100644 --- a/nix/cassandra.nix +++ b/nix/cassandra.nix @@ -6,8 +6,6 @@ let in { options = { - enable = lib.mkEnableOption name; - package = lib.mkPackageOption pkgs "cassandra" { }; listenAddress = lib.mkOption { diff --git a/nix/clickhouse/default.nix b/nix/clickhouse/default.nix index 735ce971..6a4d7d57 100644 --- a/nix/clickhouse/default.nix +++ b/nix/clickhouse/default.nix @@ -6,8 +6,6 @@ let in { options = { - enable = lib.mkEnableOption name; - package = lib.mkOption { type = types.package; description = "Which package of clickhouse to use"; diff --git a/nix/elasticsearch.nix b/nix/elasticsearch.nix index 4af27d55..c974d218 100644 --- a/nix/elasticsearch.nix +++ b/nix/elasticsearch.nix @@ -17,8 +17,6 @@ in }; } ''; - enable = lib.mkEnableOption name; - package = lib.mkPackageOption pkgs "elasticsearch7" { }; listenAddress = lib.mkOption { diff --git a/nix/grafana.nix b/nix/grafana.nix index 2e000c7b..0c83d028 100644 --- a/nix/grafana.nix +++ b/nix/grafana.nix @@ -9,8 +9,6 @@ in description = '' Configure grafana. ''; - enable = lib.mkEnableOption name; - package = lib.mkPackageOption pkgs "grafana" { }; http_port = lib.mkOption { diff --git a/nix/lib.nix b/nix/lib.nix index e02ef0c2..653329df 100644 --- a/nix/lib.nix +++ b/nix/lib.nix @@ -15,6 +15,7 @@ ]; serviceModule = { config, name, ... }: { options = { + enable = lib.mkEnableOption "Enable the ${service}. service"; dataDir = lib.mkOption { type = lib.types.str; default = "./data/${name}"; diff --git a/nix/mysql/default.nix b/nix/mysql/default.nix index 22282cad..b3434d07 100644 --- a/nix/mysql/default.nix +++ b/nix/mysql/default.nix @@ -6,8 +6,6 @@ with lib.types; let in { options = { - enable = lib.mkEnableOption "MySQL process and expose utilities"; - package = lib.mkOption { type = types.package; description = "Which package of MySQL to use"; diff --git a/nix/nginx/default.nix b/nix/nginx/default.nix index 1d5d81af..7f21b327 100644 --- a/nix/nginx/default.nix +++ b/nix/nginx/default.nix @@ -32,8 +32,6 @@ in { options = { - enable = lib.mkEnableOption "nginx"; - package = lib.mkOption { type = lib.types.package; default = pkgs.nginx; diff --git a/nix/ollama.nix b/nix/ollama.nix index 7d89b176..e8f9015b 100644 --- a/nix/ollama.nix +++ b/nix/ollama.nix @@ -8,7 +8,6 @@ let in { options = { - enable = lib.mkEnableOption "Enable the Ollama service"; package = lib.mkOption { type = types.package; default = ollamaPackage; diff --git a/nix/open-webui.nix b/nix/open-webui.nix index b80be571..bd73fa88 100644 --- a/nix/open-webui.nix +++ b/nix/open-webui.nix @@ -5,7 +5,6 @@ let in { options = { - enable = lib.mkEnableOption "Open-WebUI server"; package = lib.mkPackageOption pkgs "open-webui" { }; host = lib.mkOption { diff --git a/nix/pgadmin.nix b/nix/pgadmin.nix index a47caab4..674860f7 100644 --- a/nix/pgadmin.nix +++ b/nix/pgadmin.nix @@ -25,8 +25,6 @@ let in { options = { - enable = lib.mkEnableOption name; - package = lib.mkPackageOption pkgs "pgadmin4" { }; host = lib.mkOption { diff --git a/nix/postgres/default.nix b/nix/postgres/default.nix index 7b750f04..1df1d26f 100644 --- a/nix/postgres/default.nix +++ b/nix/postgres/default.nix @@ -5,8 +5,6 @@ with lib.types; let in { options = { - enable = lib.mkEnableOption name; - package = lib.mkOption { type = types.package; description = "Which package of postgresql to use"; diff --git a/nix/prometheus.nix b/nix/prometheus.nix index 45d6a5b7..f3fc28a0 100644 --- a/nix/prometheus.nix +++ b/nix/prometheus.nix @@ -5,8 +5,6 @@ let in { options = { - enable = lib.mkEnableOption name; - package = lib.mkPackageOption pkgs "prometheus" { }; port = lib.mkOption { diff --git a/nix/redis-cluster.nix b/nix/redis-cluster.nix index af210e3d..ea9626d7 100644 --- a/nix/redis-cluster.nix +++ b/nix/redis-cluster.nix @@ -4,8 +4,6 @@ let in { options = { - enable = lib.mkEnableOption name; - package = lib.mkPackageOption pkgs "redis" { }; nodes = lib.mkOption { diff --git a/nix/redis.nix b/nix/redis.nix index c8f4c934..decef6f0 100644 --- a/nix/redis.nix +++ b/nix/redis.nix @@ -5,8 +5,6 @@ let in { options = { - enable = lib.mkEnableOption name; - package = lib.mkPackageOption pkgs "redis" { }; bind = lib.mkOption { diff --git a/nix/searxng.nix b/nix/searxng.nix index efad80fd..600dfb14 100644 --- a/nix/searxng.nix +++ b/nix/searxng.nix @@ -5,7 +5,6 @@ let in { options = { - enable = lib.mkEnableOption name; package = lib.mkPackageOption pkgs "searxng" { }; host = lib.mkOption { diff --git a/nix/tempo.nix b/nix/tempo.nix index b2d85151..e9cdc2c0 100644 --- a/nix/tempo.nix +++ b/nix/tempo.nix @@ -8,8 +8,6 @@ in description = '' Configure tempo. ''; - enable = lib.mkEnableOption name; - package = lib.mkPackageOption pkgs "tempo" { }; httpAddress = lib.mkOption { diff --git a/nix/weaviate.nix b/nix/weaviate.nix index dd305028..d2ec7e4f 100644 --- a/nix/weaviate.nix +++ b/nix/weaviate.nix @@ -8,8 +8,6 @@ let in { options = { - enable = lib.mkEnableOption name; - package = lib.mkPackageOption pkgs "weaviate" { }; host = lib.mkOption { diff --git a/nix/zookeeper.nix b/nix/zookeeper.nix index b6ae604b..cb541399 100644 --- a/nix/zookeeper.nix +++ b/nix/zookeeper.nix @@ -4,8 +4,6 @@ with lib; { options = { - enable = mkEnableOption (lib.mdDoc "Zookeeper"); - port = mkOption { description = lib.mdDoc "Zookeeper Client port."; default = 2181;