nixos/services.cockroachdb: remove with lib;
This commit is contained in:
@@ -1,7 +1,4 @@
|
||||
{ config, lib, pkgs, utils, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.services.cockroachdb;
|
||||
crdb = cfg.package;
|
||||
@@ -32,14 +29,14 @@ let
|
||||
++ cfg.extraArgs);
|
||||
|
||||
addressOption = descr: defaultPort: {
|
||||
address = mkOption {
|
||||
type = types.str;
|
||||
address = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "localhost";
|
||||
description = "Address to bind to for ${descr}";
|
||||
};
|
||||
|
||||
port = mkOption {
|
||||
type = types.port;
|
||||
port = lib.mkOption {
|
||||
type = lib.types.port;
|
||||
default = defaultPort;
|
||||
description = "Port to bind to for ${descr}";
|
||||
};
|
||||
@@ -49,14 +46,14 @@ in
|
||||
{
|
||||
options = {
|
||||
services.cockroachdb = {
|
||||
enable = mkEnableOption "CockroachDB Server";
|
||||
enable = lib.mkEnableOption "CockroachDB Server";
|
||||
|
||||
listen = addressOption "intra-cluster communication" 26257;
|
||||
|
||||
http = addressOption "http-based Admin UI" 8080;
|
||||
|
||||
locality = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
locality = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.str;
|
||||
default = null;
|
||||
description = ''
|
||||
An ordered, comma-separated list of key-value pairs that describe the
|
||||
@@ -77,44 +74,44 @@ in
|
||||
'';
|
||||
};
|
||||
|
||||
join = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
join = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.str;
|
||||
default = null;
|
||||
description = "The addresses for connecting the node to a cluster.";
|
||||
};
|
||||
|
||||
insecure = mkOption {
|
||||
type = types.bool;
|
||||
insecure = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = false;
|
||||
description = "Run in insecure mode.";
|
||||
};
|
||||
|
||||
certsDir = mkOption {
|
||||
type = types.nullOr types.path;
|
||||
certsDir = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.path;
|
||||
default = null;
|
||||
description = "The path to the certificate directory.";
|
||||
};
|
||||
|
||||
user = mkOption {
|
||||
type = types.str;
|
||||
user = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "cockroachdb";
|
||||
description = "User account under which CockroachDB runs";
|
||||
};
|
||||
|
||||
group = mkOption {
|
||||
type = types.str;
|
||||
group = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "cockroachdb";
|
||||
description = "User account under which CockroachDB runs";
|
||||
};
|
||||
|
||||
openPorts = mkOption {
|
||||
type = types.bool;
|
||||
openPorts = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = false;
|
||||
description = "Open firewall ports for cluster communication by default";
|
||||
};
|
||||
|
||||
cache = mkOption {
|
||||
type = types.str;
|
||||
cache = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "25%";
|
||||
description = ''
|
||||
The total size for caches.
|
||||
@@ -129,8 +126,8 @@ in
|
||||
'';
|
||||
};
|
||||
|
||||
maxSqlMemory = mkOption {
|
||||
type = types.str;
|
||||
maxSqlMemory = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "25%";
|
||||
description = ''
|
||||
The maximum in-memory storage capacity available to store temporary
|
||||
@@ -145,7 +142,7 @@ in
|
||||
'';
|
||||
};
|
||||
|
||||
package = mkPackageOption pkgs "cockroachdb" {
|
||||
package = lib.mkPackageOption pkgs "cockroachdb" {
|
||||
extraDescription = ''
|
||||
This would primarily be useful to enable Enterprise Edition features
|
||||
in your own custom CockroachDB build (Nixpkgs CockroachDB binaries
|
||||
@@ -153,8 +150,8 @@ in
|
||||
'';
|
||||
};
|
||||
|
||||
extraArgs = mkOption {
|
||||
type = types.listOf types.str;
|
||||
extraArgs = lib.mkOption {
|
||||
type = lib.types.listOf lib.types.str;
|
||||
default = [];
|
||||
example = [ "--advertise-addr" "[fe80::f6f2:::]" ];
|
||||
description = ''
|
||||
@@ -165,7 +162,7 @@ in
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf config.services.cockroachdb.enable {
|
||||
config = lib.mkIf config.services.cockroachdb.enable {
|
||||
assertions = [
|
||||
{ assertion = !cfg.insecure -> cfg.certsDir != null;
|
||||
message = "CockroachDB must have a set of SSL certificates (.certsDir), or run in Insecure Mode (.insecure = true)";
|
||||
@@ -174,7 +171,7 @@ in
|
||||
|
||||
environment.systemPackages = [ crdb ];
|
||||
|
||||
users.users = optionalAttrs (cfg.user == "cockroachdb") {
|
||||
users.users = lib.optionalAttrs (cfg.user == "cockroachdb") {
|
||||
cockroachdb = {
|
||||
description = "CockroachDB Server User";
|
||||
uid = config.ids.uids.cockroachdb;
|
||||
@@ -182,7 +179,7 @@ in
|
||||
};
|
||||
};
|
||||
|
||||
users.groups = optionalAttrs (cfg.group == "cockroachdb") {
|
||||
users.groups = lib.optionalAttrs (cfg.group == "cockroachdb") {
|
||||
cockroachdb.gid = config.ids.gids.cockroachdb;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user