From e553e37abfb7e7fbd280c0b02d43ecd4331fe3c5 Mon Sep 17 00:00:00 2001 From: Josh Hoffer Date: Sun, 11 Feb 2024 14:28:25 -0800 Subject: [PATCH 1/2] nixos/mysql: remove MySQL fixed 30 second timeout Removed hard coded timeout in postScript, allow using more general systemd TimeoutStartSec instead. --- nixos/modules/services/databases/mysql.nix | 8 -------- 1 file changed, 8 deletions(-) diff --git a/nixos/modules/services/databases/mysql.nix b/nixos/modules/services/databases/mysql.nix index 128bb0862175..788a4bd43c68 100644 --- a/nixos/modules/services/databases/mysql.nix +++ b/nixos/modules/services/databases/mysql.nix @@ -379,17 +379,9 @@ in in '' ${optionalString (!isMariaDB) '' # Wait until the MySQL server is available for use - count=0 while [ ! -e /run/mysqld/mysqld.sock ] do - if [ $count -eq 30 ] - then - echo "Tried 30 times, giving up..." - exit 1 - fi - echo "MySQL daemon not yet started. Waiting for 1 second..." - count=$((count++)) sleep 1 done ''} From b445085c22189a9807fbbdd260107e4b37226241 Mon Sep 17 00:00:00 2001 From: Josh Hoffer Date: Sun, 11 Feb 2024 14:57:32 -0800 Subject: [PATCH 2/2] nixos/mysql: Use notify service type for MySQL >= 8.0 --- nixos/modules/services/databases/mysql.nix | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/nixos/modules/services/databases/mysql.nix b/nixos/modules/services/databases/mysql.nix index 788a4bd43c68..a6d71cca88de 100644 --- a/nixos/modules/services/databases/mysql.nix +++ b/nixos/modules/services/databases/mysql.nix @@ -7,6 +7,9 @@ let cfg = config.services.mysql; isMariaDB = lib.getName cfg.package == lib.getName pkgs.mariadb; + isOracle = lib.getName cfg.package == lib.getName pkgs.mysql80; + # Oracle MySQL has supported "notify" service type since 8.0 + hasNotify = isMariaDB || (isOracle && versionAtLeast cfg.package.version "8.0"); mysqldOptions = "--user=${cfg.user} --datadir=${cfg.dataDir} --basedir=${cfg.package}"; @@ -377,7 +380,7 @@ in # The super user account to use on *first* run of MySQL server superUser = if isMariaDB then cfg.user else "root"; in '' - ${optionalString (!isMariaDB) '' + ${optionalString (!hasNotify) '' # Wait until the MySQL server is available for use while [ ! -e /run/mysqld/mysqld.sock ] do @@ -469,7 +472,7 @@ in serviceConfig = mkMerge [ { - Type = if isMariaDB then "notify" else "simple"; + Type = if hasNotify then "notify" else "simple"; Restart = "on-abort"; RestartSec = "5s";