Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nixos/*: Add types to the database module options #76667

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 1 addition & 10 deletions nixos/modules/services/databases/clickhouse.nix
Expand Up @@ -8,16 +8,7 @@ with lib;
###### interface

options = {

services.clickhouse = {

enable = mkOption {
default = false;
description = "Whether to enable ClickHouse database server.";
};

};

services.clickhouse.enable = mkEnableOption "ClickHouse database server";
};


Expand Down
10 changes: 4 additions & 6 deletions nixos/modules/services/databases/firebird.nix
Expand Up @@ -40,12 +40,7 @@ in

services.firebird = {

enable = mkOption {
default = false;
description = ''
Whether to enable the Firebird super server.
'';
};
enable = mkEnableOption "the Firebird super server";

package = mkOption {
default = pkgs.firebirdSuper;
Expand All @@ -64,20 +59,23 @@ in

port = mkOption {
default = "3050";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we use an int here if that option now represents a port?

type = types.port;
description = ''
Port Firebird uses.
'';
};

user = mkOption {
default = "firebird";
type = types.str;
description = ''
User account under which firebird runs.
'';
};

baseDir = mkOption {
default = "/var/db/firebird"; # ubuntu is using /var/lib/firebird/2.1/data/.. ?
type = types.str;
description = ''
Location containing data/ and system/ directories.
data/ stores the databases, system/ stores the password database security2.fdb.
Expand Down
23 changes: 12 additions & 11 deletions nixos/modules/services/databases/memcached.nix
Expand Up @@ -16,45 +16,46 @@ in

options = {

services.memcached = {
services.memcached = with types; {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(nitpick, probably irrelevant) I'm not sure if we actually benefit from adding even more with ...; expressions. While I think that those are pretty handy and convenient, I know that especially beginners will have a hard time understanding where a variable is actually coming from if it was passed through several expressions using with ...;.


enable = mkOption {
default = false;
description = "
Whether to enable Memcached.
";
};
enable = mkEnableOption "Memcached";

user = mkOption {
type = str;
default = "memcached";
description = "The user to run Memcached as";
};

listen = mkOption {
type = str;
default = "127.0.0.1";
description = "The IP address to bind to";
description = "The IP address to bind to.";
};

port = mkOption {
type = port;
default = 11211;
description = "The port to bind to";
description = "The port to bind to.";
};

enableUnixSocket = mkEnableOption "unix socket at /run/memcached/memcached.sock";

maxMemory = mkOption {
type = ints.unsigned;
default = 64;
description = "The maximum amount of memory to use for storage, in megabytes.";
};

maxConnections = mkOption {
type = ints.unsigned;
default = 1024;
description = "The maximum number of simultaneous connections";
description = "The maximum number of simultaneous connections.";
};

extraOptions = mkOption {
type = listOf str;
default = [];
description = "A list of extra options that will be added as a suffix when running memcached";
description = "A list of extra options that will be added as a suffix when running memcached.";
};
};

Expand Down
14 changes: 8 additions & 6 deletions nixos/modules/services/databases/mongodb.nix
Expand Up @@ -29,12 +29,7 @@ in

services.mongodb = {

enable = mkOption {
default = false;
description = "
Whether to enable the MongoDB server.
";
};
enable = mkEnableOption "the MongoDB server";

package = mkOption {
default = pkgs.mongodb;
Expand All @@ -46,16 +41,19 @@ in
};

user = mkOption {
type = types.str;
default = "mongodb";
description = "User account under which MongoDB runs";
};

bind_ip = mkOption {
type = types.str;
default = "127.0.0.1";
description = "IP to bind to";
};

quiet = mkOption {
type = types.bool;
default = false;
description = "quieter output";
};
Expand All @@ -73,16 +71,19 @@ in
};

dbpath = mkOption {
type = types.str;
default = "/var/db/mongodb";
description = "Location where MongoDB stores its files";
};

pidFile = mkOption {
type = types.str;
default = "/run/mongodb.pid";
description = "Location of MongoDB pid file";
};

replSetName = mkOption {
type = types.str;
default = "";
description = ''
If this instance is part of a replica set, set its name here.
Expand All @@ -91,6 +92,7 @@ in
};

extraConfig = mkOption {
type = types.lines;
default = "";
example = ''
storage.journal.enabled: false
Expand Down
37 changes: 25 additions & 12 deletions nixos/modules/services/databases/redis.nix
Expand Up @@ -46,16 +46,12 @@ in

services.redis = {

enable = mkOption {
type = types.bool;
default = false;
description = ''
Whether to enable the Redis server. Note that the NixOS module for
Redis disables kernel support for Transparent Huge Pages (THP),
because this features causes major performance problems for Redis,
e.g. (https://redis.io/topics/latency).
'';
};
enable = mkEnableOption ''
Whether to enable the Redis server. Note that the NixOS module for
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mkEnableOption's description is basically Whether to enable <name>, while <name> is the first argument passed to mkEnableOption. Thereforce I think that your text might seem rather confusing when looking at it from the manual. I'd suggest that you either adjust your text or that you do e.g. (mkEnableOption "opt-name") // { description = ''A little more details''; }.

Redis disables kernel support for Transparent Huge Pages (THP),
because this features causes major performance problems for Redis,
e.g. (https://redis.io/topics/latency)
'';

package = mkOption {
type = types.package;
Expand Down Expand Up @@ -134,12 +130,29 @@ in
};

slaveOf = mkOption {
default = null; # { ip, port }
description = "An attribute set with two attributes: ip and port to which this redis instance acts as a slave.";
type = with types; nullOr (submodule ({ ... }: {
options = {
ip = mkOption {
type = str;
description = "IP of the Redis master";
example = "192.168.1.100";
};

port = mkOption {
type = port;
description = "port of the Redis master";
default = 6379;
};
};
}));

default = null;
description = "IP and port to which this redis instance acts as a slave.";
example = { ip = "192.168.1.100"; port = 6379; };
};

masterAuth = mkOption {
type = types.str;
default = null;
description = ''If the master is password protected (using the requirePass configuration)
it is possible to tell the slave to authenticate before starting the replication synchronization
Expand Down
12 changes: 7 additions & 5 deletions nixos/modules/services/databases/virtuoso.nix
Expand Up @@ -11,36 +11,38 @@ with lib;

options = {

services.virtuoso = {
services.virtuoso = with types; {

enable = mkOption {
default = false;
description = "Whether to enable Virtuoso Opensource database server.";
};
enable = mkEnableOption "Virtuoso Opensource database server";

config = mkOption {
type = lines;
default = "";
description = "Extra options to put into Virtuoso configuration file.";
};

parameters = mkOption {
type = lines;
default = "";
description = "Extra options to put into [Parameters] section of Virtuoso configuration file.";
};

listenAddress = mkOption {
type = str;
default = "1111";
example = "myserver:1323";
description = "ip:port or port to listen on.";
};

httpListenAddress = mkOption {
type = nullOr str;
default = null;
example = "myserver:8080";
description = "ip:port or port for Virtuoso HTTP server to listen on.";
};

dirsAllowed = mkOption {
type = nullOr str; # XXX Maybe use a list in the future?
default = null;
example = "/www, /home/";
description = "A list of directories Virtuoso is allowed to access";
Expand Down