mariadb: change location configuration file to /etc/my.cnf
This commit is contained in:
parent
c4852e3d31
commit
953be3e283
1 changed files with 17 additions and 17 deletions
|
@ -29,21 +29,6 @@ let
|
||||||
installOptions =
|
installOptions =
|
||||||
"${mysqldAndInstallOptions} ${lib.optionalString isMysqlAtLeast57 "--insecure"}";
|
"${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
|
in
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -242,6 +227,21 @@ in
|
||||||
|
|
||||||
environment.systemPackages = [mysql];
|
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
|
systemd.services.mysql = let
|
||||||
hasNotify = (cfg.package == pkgs.mariadb);
|
hasNotify = (cfg.package == pkgs.mariadb);
|
||||||
in {
|
in {
|
||||||
|
@ -263,7 +263,7 @@ in
|
||||||
if ! test -e ${cfg.dataDir}/mysql; then
|
if ! test -e ${cfg.dataDir}/mysql; then
|
||||||
mkdir -m 0700 -p ${cfg.dataDir}
|
mkdir -m 0700 -p ${cfg.dataDir}
|
||||||
chown -R ${cfg.user} ${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
|
touch /tmp/mysql_init
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -274,7 +274,7 @@ in
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
Type = if hasNotify then "notify" else "simple";
|
Type = if hasNotify then "notify" else "simple";
|
||||||
RuntimeDirectory = "mysqld";
|
RuntimeDirectory = "mysqld";
|
||||||
ExecStart = "${mysql}/bin/mysqld --defaults-extra-file=${myCnf} ${mysqldOptions}";
|
ExecStart = "${mysql}/bin/mysqld --defaults-file=/etc/my.cnf ${mysqldOptions}";
|
||||||
};
|
};
|
||||||
|
|
||||||
postStart = ''
|
postStart = ''
|
||||||
|
|
Loading…
Reference in a new issue