nixos/mysql: minor cleanup and formatting
This commit is contained in:
@@ -62,7 +62,7 @@ in
|
||||
Group account under which MySQL runs.
|
||||
|
||||
<note><para>
|
||||
If left as the default value this user will automatically be created
|
||||
If left as the default value this group will automatically be created
|
||||
on system activation, otherwise you are responsible for
|
||||
ensuring the user exists before the MySQL service starts.
|
||||
</para></note>
|
||||
@@ -283,7 +283,7 @@ in
|
||||
};
|
||||
|
||||
masterPort = mkOption {
|
||||
type = types.int;
|
||||
type = types.port;
|
||||
default = 3306;
|
||||
description = "Port number on which the MySQL master server runs.";
|
||||
};
|
||||
@@ -295,7 +295,7 @@ in
|
||||
|
||||
###### implementation
|
||||
|
||||
config = mkIf config.services.mysql.enable {
|
||||
config = mkIf cfg.enable {
|
||||
|
||||
services.mysql.dataDir =
|
||||
mkDefault (if versionAtLeast config.system.stateVersion "17.09" then "/var/lib/mysql"
|
||||
@@ -334,16 +334,14 @@ in
|
||||
|
||||
environment.etc."my.cnf".source = cfg.configFile;
|
||||
|
||||
systemd.services.mysql = let
|
||||
hasNotify = isMariaDB;
|
||||
in {
|
||||
systemd.services.mysql = {
|
||||
description = "MySQL Server";
|
||||
|
||||
after = [ "network.target" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
restartTriggers = [ cfg.configFile ];
|
||||
|
||||
unitConfig.RequiresMountsFor = "${cfg.dataDir}";
|
||||
unitConfig.RequiresMountsFor = cfg.dataDir;
|
||||
|
||||
path = [
|
||||
# Needed for the mysql_install_db command in the preStart script
|
||||
@@ -379,7 +377,7 @@ in
|
||||
# The super user account to use on *first* run of MySQL server
|
||||
superUser = if isMariaDB then cfg.user else "root";
|
||||
in ''
|
||||
${optionalString (!hasNotify) ''
|
||||
${optionalString (!isMariaDB) ''
|
||||
# Wait until the MySQL server is available for use
|
||||
count=0
|
||||
while [ ! -e /run/mysqld/mysqld.sock ]
|
||||
@@ -479,7 +477,7 @@ in
|
||||
|
||||
serviceConfig = mkMerge [
|
||||
{
|
||||
Type = if hasNotify then "notify" else "simple";
|
||||
Type = if isMariaDB then "notify" else "simple";
|
||||
Restart = "on-abort";
|
||||
RestartSec = "5s";
|
||||
|
||||
@@ -519,7 +517,5 @@ in
|
||||
})
|
||||
];
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user