From 80283570848734d8473b6434141ce8f4406720e7 Mon Sep 17 00:00:00 2001 From: "William A. Kennington III" Date: Tue, 31 Mar 2015 16:16:12 -0700 Subject: [PATCH] nixos/mysql: Cleanups --- nixos/modules/services/databases/mysql.nix | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/nixos/modules/services/databases/mysql.nix b/nixos/modules/services/databases/mysql.nix index 1e2400d84b36..05b13492052a 100644 --- a/nixos/modules/services/databases/mysql.nix +++ b/nixos/modules/services/databases/mysql.nix @@ -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