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