nixos/mysql: Use notify service type for MySQL >= 8.0

This commit is contained in:
Josh Hoffer 2024-02-11 14:57:32 -08:00
parent e553e37abf
commit b445085c22

View File

@ -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";