git.iko.soy/typeable/nixpkgs
on master help sign in
mariadb: change location configuration file to /etc/my.cnf
commit953be3e283459c89d89e4ec204472aa880a85674 authorIzorkin <izorkin@elven.pw> dateSat 1 Dec 2018, 15:10 (8 years ago) parentc4852e3
1 file changed+17−17
nixos/modules/services/databases/mysql.nix+17−17
nixos/modules/services/databases/mysql.nix+17−17
@@ -29,21 +29,6 @@ let
2929 installOptions =
3030 "${mysqldAndInstallOptions} ${lib.optionalString isMysqlAtLeast57 "--insecure"}";
3131
32− myCnf = pkgs.writeText "my.cnf"
33− ''
34− [mysqld]
35− port = ${toString cfg.port}
36− datadir = ${cfg.dataDir}
37− ${optionalString (cfg.bind != null) "bind-address = ${cfg.bind}" }
38− ${optionalString (cfg.replication.role == "master" || cfg.replication.role == "slave") "log-bin=mysql-bin"}
39− ${optionalString (cfg.replication.role == "master" || cfg.replication.role == "slave") "server-id = ${toString cfg.replication.serverId}"}
40− ${optionalString (cfg.ensureUsers != [])
41− ''
42− plugin-load-add = auth_socket.so
43− ''}
44− ${cfg.extraOptions}
45− '';
46−
4732in
4833
4934{
@@ -242,6 +227,21 @@ in
242227
243228 environment.systemPackages = [mysql];
244229
230+ environment.etc."my.cnf".text =
231+ ''
232+ [mysqld]
233+ port = ${toString cfg.port}
234+ datadir = ${cfg.dataDir}
235+ ${optionalString (cfg.bind != null) "bind-address = ${cfg.bind}" }
236+ ${optionalString (cfg.replication.role == "master" || cfg.replication.role == "slave") "log-bin=mysql-bin"}
237+ ${optionalString (cfg.replication.role == "master" || cfg.replication.role == "slave") "server-id = ${toString cfg.replication.serverId}"}
238+ ${optionalString (cfg.ensureUsers != [])
239+ ''
240+ plugin-load-add = auth_socket.so
241+ ''}
242+ ${cfg.extraOptions}
243+ '';
244+
245245 systemd.services.mysql = let
246246 hasNotify = (cfg.package == pkgs.mariadb);
247247 in {
@@ -263,7 +263,7 @@ in
263263 if ! test -e ${cfg.dataDir}/mysql; then
264264 mkdir -m 0700 -p ${cfg.dataDir}
265265 chown -R ${cfg.user} ${cfg.dataDir}
266− ${mysql}/bin/mysql_install_db ${installOptions}
266+ ${mysql}/bin/mysql_install_db --defaults-file=/etc/my.cnf ${installOptions}
267267 touch /tmp/mysql_init
268268 fi
269269
@@ -274,7 +274,7 @@ in
274274 serviceConfig = {
275275 Type = if hasNotify then "notify" else "simple";
276276 RuntimeDirectory = "mysqld";
277− ExecStart = "${mysql}/bin/mysqld --defaults-extra-file=${myCnf} ${mysqldOptions}";
277+ ExecStart = "${mysql}/bin/mysqld --defaults-file=/etc/my.cnf ${mysqldOptions}";
278278 };
279279
280280 postStart = ''