diff options
author | Shea Levy <shea@shealevy.com> | 2014-02-26 07:54:04 -0500 |
---|---|---|
committer | Shea Levy <shea@shealevy.com> | 2014-02-26 07:54:12 -0500 |
commit | 1ce6fff4e21906a3e6cfd26fdf4372f7501541cd (patch) | |
tree | 79fc51e845dd8297ecaa8a8dc49c981461f1650a /nixos/modules/services/databases/mysql.nix | |
parent | 2fd60ee9484fbbb412f80672367199409d58147c (diff) | |
download | nixpkgs-1ce6fff4e21906a3e6cfd26fdf4372f7501541cd.tar nixpkgs-1ce6fff4e21906a3e6cfd26fdf4372f7501541cd.tar.gz nixpkgs-1ce6fff4e21906a3e6cfd26fdf4372f7501541cd.tar.bz2 nixpkgs-1ce6fff4e21906a3e6cfd26fdf4372f7501541cd.tar.lz nixpkgs-1ce6fff4e21906a3e6cfd26fdf4372f7501541cd.tar.xz nixpkgs-1ce6fff4e21906a3e6cfd26fdf4372f7501541cd.tar.zst nixpkgs-1ce6fff4e21906a3e6cfd26fdf4372f7501541cd.zip |
Merge mysql55 module into mysql
This also removes the default for services.mysql.package, as this should not generally be updated automatically if we change the mysql attribute
Diffstat (limited to 'nixos/modules/services/databases/mysql.nix')
-rw-r--r-- | nixos/modules/services/databases/mysql.nix | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/nixos/modules/services/databases/mysql.nix b/nixos/modules/services/databases/mysql.nix index 8be05a27cdc..62fbc2a1415 100644 --- a/nixos/modules/services/databases/mysql.nix +++ b/nixos/modules/services/databases/mysql.nix @@ -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 = @@ -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} @@ -47,7 +51,8 @@ in }; package = mkOption { - default = pkgs.mysql; + type = types.package; + example = literalExample "pkgs.mysql"; description = " Which MySQL derivation to use. "; @@ -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 = '' @@ -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 |