Skip to content

Commit

Permalink
Merge mysql55 module into mysql
Browse files Browse the repository at this point in the history
This also removes the default for services.mysql.package, as this should
not generally be updated automatically if we change the mysql attribute
  • Loading branch information
shlevy committed Feb 26, 2014
1 parent 2fd60ee commit 1ce6fff
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 251 deletions.
2 changes: 2 additions & 0 deletions nixos/modules/rename.nix
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ in zipModules ([]
++ obsolete [ "services" "mesa" "s3tcSupport" ] [ "hardware" "opengl" "s3tcSupport" ]
++ obsolete [ "services" "mesa" "videoDrivers" ] [ "hardware" "opengl" "videoDrivers" ]

++ obsolete [ "services" "mysql55" ] [ "services" "mysql" ]

# Options that are obsolete and have no replacement.
++ obsolete' [ "boot" "loader" "grub" "bootDevice" ]
++ obsolete' [ "boot" "initrd" "luks" "enable" ]
Expand Down
21 changes: 18 additions & 3 deletions nixos/modules/services/databases/mysql.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ let

mysql = cfg.package;

is55 = mysql.mysqlVersion == "5.5";

mysqldDir = if is55 then "${mysql}/bin" else "${mysql}/libexec";

pidFile = "${cfg.pidDir}/mysqld.pid";

mysqldOptions =
Expand All @@ -19,7 +23,7 @@ let
[mysqld]
${optionalString (cfg.replication.role == "master" || cfg.replication.role == "slave") "log-bin=mysql-bin"}
${optionalString (cfg.replication.role == "master" || cfg.replication.role == "slave") "server-id = ${toString cfg.replication.serverId}"}
${optionalString (cfg.replication.role == "slave")
${optionalString (cfg.replication.role == "slave" && !is55)
''
master-host = ${cfg.replication.masterHost}
master-user = ${cfg.replication.masterUser}
Expand Down Expand Up @@ -47,7 +51,8 @@ in
};

package = mkOption {
default = pkgs.mysql;
type = types.package;
example = literalExample "pkgs.mysql";
description = "
Which MySQL derivation to use.
";
Expand Down Expand Up @@ -176,7 +181,7 @@ in
chown -R ${cfg.user} ${cfg.pidDir}
'';

serviceConfig.ExecStart = "${mysql}/libexec/mysqld --defaults-extra-file=${myCnf} ${mysqldOptions}";
serviceConfig.ExecStart = "${mysqldDir}/mysqld --defaults-extra-file=${myCnf} ${mysqldOptions}";

postStart =
''
Expand Down Expand Up @@ -216,6 +221,16 @@ in
fi
'') cfg.initialDatabases}
${optionalString (cfg.replication.role == "slave" && is55)
''
# Set up the replication master
( echo "stop slave;"
echo "change master to master_host='${cfg.replication.masterHost}', master_user='${cfg.replication.masterUser}', master_password='${cfg.replication.masterPassword}';"
echo "start slave;"
) | ${mysql}/bin/mysql -u root -N
''}
${optionalString (cfg.initialScript != null)
''
# Execute initial script
Expand Down
248 changes: 0 additions & 248 deletions nixos/modules/services/databases/mysql55.nix

This file was deleted.

2 changes: 2 additions & 0 deletions pkgs/servers/sql/mariadb/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ stdenv.mkDerivation rec {

enableParallelBuilding = true;

passthru.mysqlVersion = "5.5";

meta = {
description = "An enhanced, drop-in replacement for MySQL";
homepage = https://mariadb.org/;
Expand Down
2 changes: 2 additions & 0 deletions pkgs/servers/sql/mysql/5.1.x.nix
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ stdenv.mkDerivation rec {
rm -rf $out/mysql-test $out/sql-bench $out/share/info
'';

passthru.mysqlVersion = "5.1";

meta = {
homepage = http://www.mysql.com/;
description = "The world's most popular open source database";
Expand Down
2 changes: 2 additions & 0 deletions pkgs/servers/sql/mysql/5.5.x.nix
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ stdenv.mkDerivation rec {
rm -rf $out/mysql-test $out/sql-bench
'';

passthru.mysqlVersion = "5.5";

meta = {
homepage = http://www.mysql.com/;
description = "The world's most popular open source database";
Expand Down

2 comments on commit 1ce6fff

@domenkozar
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in job ‘nixos.tests.mysql.x86_64-linux’:
The option `services.mysql.package' is used but not defined.

in job ‘nixos.tests.mysql.i686-linux’:
The option `services.mysql.package' is used but not defined.

in job ‘nixos.tests.mysql_replication.x86_64-linux’:
The option `services.mysql.package' is used but not defined.

in job ‘nixos.tests.mysql_replication.i686-linux’:
The option `services.mysql.package' is used but not defined.

@shlevy
Copy link
Member Author

@shlevy shlevy commented on 1ce6fff Feb 28, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, thanks! 691f6c4

Please sign in to comment.