diff options
author | Florian Klink <flokli@flokli.de> | 2019-05-17 00:10:34 +0200 |
---|---|---|
committer | Florian Klink <flokli@flokli.de> | 2019-05-31 22:20:42 +0200 |
commit | 50dda813e24db454b376866906e9281b7dafcb3a (patch) | |
tree | 58317dfd190bd70edcbec599b23cd7016313baf7 /nixos/modules/services/databases/mysql.nix | |
parent | 6c7586228c70ce119cef4209ee288d0a3316086f (diff) | |
download | nixpkgs-50dda813e24db454b376866906e9281b7dafcb3a.tar nixpkgs-50dda813e24db454b376866906e9281b7dafcb3a.tar.gz nixpkgs-50dda813e24db454b376866906e9281b7dafcb3a.tar.bz2 nixpkgs-50dda813e24db454b376866906e9281b7dafcb3a.tar.lz nixpkgs-50dda813e24db454b376866906e9281b7dafcb3a.tar.xz nixpkgs-50dda813e24db454b376866906e9281b7dafcb3a.tar.zst nixpkgs-50dda813e24db454b376866906e9281b7dafcb3a.zip |
nixos/mysql: use systemd.tmpfiles to setup dataDir and pidDir
We need to keep using `RuntimeDirectory=mysqld`, which translates to `/run/mysqld`, as this is used for the location of the file socket, that could differ with what is configured via `cfg.pidDir`.
Diffstat (limited to 'nixos/modules/services/databases/mysql.nix')
-rw-r--r-- | nixos/modules/services/databases/mysql.nix | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/nixos/modules/services/databases/mysql.nix b/nixos/modules/services/databases/mysql.nix index 7e3c230fff7..daa3b6c34dd 100644 --- a/nixos/modules/services/databases/mysql.nix +++ b/nixos/modules/services/databases/mysql.nix @@ -296,6 +296,11 @@ in ${cfg.extraOptions} ''; + systemd.tmpfiles.rules = [ + "d '${cfg.dataDir}' 0700 ${cfg.user} mysql -" + "d '${cfg.pidDir}' 0755 ${cfg.user} mysql -" + ]; + systemd.services.mysql = let hasNotify = (cfg.package == pkgs.mariadb); in { @@ -316,19 +321,17 @@ in preStart = '' if ! test -e ${cfg.dataDir}/mysql; then - mkdir -m 0700 -p ${cfg.dataDir} - chown -R ${cfg.user} ${cfg.dataDir} ${mysql}/bin/mysql_install_db --defaults-file=/etc/my.cnf ${installOptions} touch /tmp/mysql_init fi - mkdir -m 0755 -p ${cfg.pidDir} - chown -R ${cfg.user} ${cfg.pidDir} ''; serviceConfig = { Type = if hasNotify then "notify" else "simple"; + # /run/mysqld needs to be created in addition to pidDir, as they could point to different locations RuntimeDirectory = "mysqld"; + RuntimeDirectoryMode = "0755"; # The last two environment variables are used for starting Galera clusters ExecStart = "${mysql}/bin/mysqld --defaults-file=/etc/my.cnf ${mysqldOptions} $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION"; }; |