Skip to content
Permalink
Browse files

Merge pull request #51314 from Izorkin/mariadb-my.cnf

mariadb: change location configuration file to /etc/my.cnf
  • Loading branch information
grahamc committed Dec 7, 2018
2 parents 716a38d + 953be3e commit ca3f089a836ce970f8037485c2b65034de14269f
Showing with 17 additions and 17 deletions.
  1. +17 −17 nixos/modules/services/databases/mysql.nix
@@ -29,21 +29,6 @@ let
installOptions =
"${mysqldAndInstallOptions} ${lib.optionalString isMysqlAtLeast57 "--insecure"}";

myCnf = pkgs.writeText "my.cnf"
''
[mysqld]
port = ${toString cfg.port}
datadir = ${cfg.dataDir}
${optionalString (cfg.bind != null) "bind-address = ${cfg.bind}" }
${optionalString (cfg.replication.role == "master" || cfg.replication.role == "slave") "log-bin=mysql-bin"}
${optionalString (cfg.replication.role == "master" || cfg.replication.role == "slave") "server-id = ${toString cfg.replication.serverId}"}
${optionalString (cfg.ensureUsers != [])
''
plugin-load-add = auth_socket.so
''}
${cfg.extraOptions}
'';

in

{
@@ -242,6 +227,21 @@ in

environment.systemPackages = [mysql];

environment.etc."my.cnf".text =
''
[mysqld]
port = ${toString cfg.port}
datadir = ${cfg.dataDir}
${optionalString (cfg.bind != null) "bind-address = ${cfg.bind}" }
${optionalString (cfg.replication.role == "master" || cfg.replication.role == "slave") "log-bin=mysql-bin"}
${optionalString (cfg.replication.role == "master" || cfg.replication.role == "slave") "server-id = ${toString cfg.replication.serverId}"}
${optionalString (cfg.ensureUsers != [])
''
plugin-load-add = auth_socket.so
''}
${cfg.extraOptions}
'';

systemd.services.mysql = let
hasNotify = (cfg.package == pkgs.mariadb);
in {
@@ -263,7 +263,7 @@ in
if ! test -e ${cfg.dataDir}/mysql; then
mkdir -m 0700 -p ${cfg.dataDir}
chown -R ${cfg.user} ${cfg.dataDir}
${mysql}/bin/mysql_install_db ${installOptions}
${mysql}/bin/mysql_install_db --defaults-file=/etc/my.cnf ${installOptions}
touch /tmp/mysql_init
fi
@@ -274,7 +274,7 @@ in
serviceConfig = {
Type = if hasNotify then "notify" else "simple";
RuntimeDirectory = "mysqld";
ExecStart = "${mysql}/bin/mysqld --defaults-extra-file=${myCnf} ${mysqldOptions}";
ExecStart = "${mysql}/bin/mysqld --defaults-file=/etc/my.cnf ${mysqldOptions}";
};

postStart = ''

0 comments on commit ca3f089

Please sign in to comment.
You can’t perform that action at this time.