Merge pull request #168292 from whentze/cockroach-module-improvements
nixos/cockroachdb: add `extraArgs` and properly escape systemd exec args
This commit is contained in:
commit
398973f7eb
|
@ -1,4 +1,4 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
{ config, lib, pkgs, utils, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
|
@ -6,32 +6,30 @@ let
|
|||
cfg = config.services.cockroachdb;
|
||||
crdb = cfg.package;
|
||||
|
||||
escape = builtins.replaceStrings ["%"] ["%%"];
|
||||
ifNotNull = v: s: optionalString (v != null) s;
|
||||
|
||||
startupCommand = lib.concatStringsSep " "
|
||||
[ # Basic startup
|
||||
"${crdb}/bin/cockroach start"
|
||||
startupCommand = utils.escapeSystemdExecArgs
|
||||
([
|
||||
# Basic startup
|
||||
"${crdb}/bin/cockroach"
|
||||
"start"
|
||||
"--logtostderr"
|
||||
"--store=/var/lib/cockroachdb"
|
||||
(ifNotNull cfg.locality "--locality='${cfg.locality}'")
|
||||
|
||||
# WebUI settings
|
||||
"--http-addr='${cfg.http.address}:${toString cfg.http.port}'"
|
||||
"--http-addr=${cfg.http.address}:${toString cfg.http.port}"
|
||||
|
||||
# Cluster listen address
|
||||
"--listen-addr='${cfg.listen.address}:${toString cfg.listen.port}'"
|
||||
"--listen-addr=${cfg.listen.address}:${toString cfg.listen.port}"
|
||||
|
||||
# Cluster configuration
|
||||
(ifNotNull cfg.join "--join=${cfg.join}")
|
||||
|
||||
# Cache and memory settings. Must be escaped.
|
||||
"--cache='${escape cfg.cache}'"
|
||||
"--max-sql-memory='${escape cfg.maxSqlMemory}'"
|
||||
# Cache and memory settings.
|
||||
"--cache=${cfg.cache}"
|
||||
"--max-sql-memory=${cfg.maxSqlMemory}"
|
||||
|
||||
# Certificate/security settings.
|
||||
(if cfg.insecure then "--insecure" else "--certs-dir=${cfg.certsDir}")
|
||||
];
|
||||
]
|
||||
++ lib.optional (cfg.join != null) "--join=${cfg.join}"
|
||||
++ lib.optional (cfg.locality != null) "--locality=${cfg.locality}"
|
||||
++ cfg.extraArgs);
|
||||
|
||||
addressOption = descr: defaultPort: {
|
||||
address = mkOption {
|
||||
|
@ -159,6 +157,16 @@ in
|
|||
only contain open source features and open source code).
|
||||
'';
|
||||
};
|
||||
|
||||
extraArgs = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [];
|
||||
example = [ "--advertise-addr" "[fe80::f6f2:::]" ];
|
||||
description = ''
|
||||
Extra CLI arguments passed to <command>cockroach start</command>.
|
||||
For the full list of supported argumemnts, check <link xlink:href="https://www.cockroachlabs.com/docs/stable/cockroach-start.html#flags"/>
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue