nixos/mysql: remove services.mysql.extraOptions in favor of services.mysql.settings

This commit is contained in:
Aaron Andersen
2021-12-18 21:00:04 -05:00
parent f1d1d319ae
commit 76457da532

View File

@@ -11,10 +11,8 @@ let
mysqldOptions = mysqldOptions =
"--user=${cfg.user} --datadir=${cfg.dataDir} --basedir=${cfg.package}"; "--user=${cfg.user} --datadir=${cfg.dataDir} --basedir=${cfg.package}";
settingsFile = pkgs.writeText "my.cnf" ( format = pkgs.formats.ini { listsAsDuplicateKeys = true; };
generators.toINI { listsAsDuplicateKeys = true; } cfg.settings + configFile = format.generate "my.cnf" cfg.settings;
optionalString (cfg.extraOptions != null) "[mysqld]\n${cfg.extraOptions}"
);
in in
@@ -22,6 +20,7 @@ in
imports = [ imports = [
(mkRemovedOptionModule [ "services" "mysql" "pidDir" ] "Don't wait for pidfiles, describe dependencies through systemd.") (mkRemovedOptionModule [ "services" "mysql" "pidDir" ] "Don't wait for pidfiles, describe dependencies through systemd.")
(mkRemovedOptionModule [ "services" "mysql" "rootPassword" ] "Use socket authentication or set the password outside of the nix store.") (mkRemovedOptionModule [ "services" "mysql" "rootPassword" ] "Use socket authentication or set the password outside of the nix store.")
(mkRemovedOptionModule [ "services" "mysql" "extraOptions" ] "Use services.mysql.settings.mysqld instead.")
]; ];
###### interface ###### interface
@@ -96,8 +95,10 @@ in
configFile = mkOption { configFile = mkOption {
type = types.path; type = types.path;
default = settingsFile; default = configFile;
defaultText = literalExpression "settingsFile"; defaultText = ''
A configuration file automatically generated by NixOS.
'';
description = '' description = ''
Override the configuration file used by MySQL. By default, Override the configuration file used by MySQL. By default,
NixOS generates one automatically from <option>services.mysql.settings</option>. NixOS generates one automatically from <option>services.mysql.settings</option>.
@@ -115,7 +116,7 @@ in
}; };
settings = mkOption { settings = mkOption {
type = with types; attrsOf (attrsOf (oneOf [ bool int str (listOf str) ])); type = format.type;
default = {}; default = {};
description = '' description = ''
MySQL configuration. Refer to MySQL configuration. Refer to
@@ -148,23 +149,6 @@ in
''; '';
}; };
extraOptions = mkOption {
type = with types; nullOr lines;
default = null;
example = ''
key_buffer_size = 6G
table_cache = 1600
log-error = /var/log/mysql_err.log
'';
description = ''
Provide extra options to the MySQL configuration file.
Please note, that these options are added to the
<literal>[mysqld]</literal> section so you don't need to explicitly
state it again.
'';
};
initialDatabases = mkOption { initialDatabases = mkOption {
type = types.listOf (types.submodule { type = types.listOf (types.submodule {
options = { options = {
@@ -324,8 +308,6 @@ in
config = mkIf config.services.mysql.enable { config = mkIf config.services.mysql.enable {
warnings = optional (cfg.extraOptions != null) "services.mysql.`extraOptions` is deprecated, please use services.mysql.`settings`.";
services.mysql.dataDir = services.mysql.dataDir =
mkDefault (if versionAtLeast config.system.stateVersion "17.09" then "/var/lib/mysql" mkDefault (if versionAtLeast config.system.stateVersion "17.09" then "/var/lib/mysql"
else "/var/mysql"); else "/var/mysql");