nixos/mysql: Cleanups

This commit is contained in:
William A. Kennington III 2015-03-31 16:16:12 -07:00
parent b74833bc20
commit 8028357084

View File

@ -8,7 +8,7 @@ let
mysql = cfg.package;
is55 = mysql.mysqlVersion == "5.5";
atLeast55 = versionAtLeast mysql.mysqlVersion "5.5";
pidFile = "${cfg.pidDir}/mysqld.pid";
@ -22,7 +22,7 @@ let
port = ${toString cfg.port}
${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.replication.role == "slave" && !is55)
${optionalString (cfg.replication.role == "slave" && !atLeast55)
''
master-host = ${cfg.replication.masterHost}
master-user = ${cfg.replication.masterUser}
@ -73,7 +73,7 @@ in
};
pidDir = mkOption {
default = "/var/run/mysql";
default = "/run/mysqld";
description = "Location of the file which stores the PID of the MySQL server";
};
@ -178,6 +178,10 @@ in
mkdir -m 0700 -p ${cfg.pidDir}
chown -R ${cfg.user} ${cfg.pidDir}
# Make the socket directory
mkdir -m 0700 -p /run/mysqld
chown -R ${cfg.user} /run/mysqld
'';
serviceConfig.ExecStart = "${mysql}/bin/mysqld --defaults-extra-file=${myCnf} ${mysqldOptions}";
@ -186,7 +190,7 @@ in
''
# Wait until the MySQL server is available for use
count=0
while [ ! -e /tmp/mysql.sock ]
while [ ! -e /run/mysqld/mysqld.sock ]
do
if [ $count -eq 30 ]
then
@ -220,7 +224,7 @@ in
fi
'') cfg.initialDatabases}
${optionalString (cfg.replication.role == "slave" && is55)
${optionalString (cfg.replication.role == "slave" && atLeast55)
''
# Set up the replication master