Skip to content

nixos/mysql: fix service so it works with mysql80 package [20.03 backport] #83254

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 24, 2020

Conversation

aanderse
Copy link
Member

Motivation for this change

I found out that the mysql80 package is broken with the mysql module 😱 I think this deserves a 20.03 backport.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

Sorry, something went wrong.

Verified

This commit was signed with the committer’s verified signature. The key has expired.
lucasfernog Lucas Fernandes Nogueira
(cherry picked from commit 3474b55)

Verified

This commit was signed with the committer’s verified signature. The key has expired.
lucasfernog Lucas Fernandes Nogueira
(cherry picked from commit 6c47902)
@aanderse
Copy link
Member Author

@GrahamcOfBorg test mysql

@ofborg ofborg bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux labels Mar 24, 2020
@aanderse
Copy link
Member Author

ping @NixOS/nixos-release-managers - currently services.mysql is broken if you specify services.mysql.package = pkgs.mysql80;, and minimal non breaking changes to the module can correct this.

Comment on lines +302 to 311
preStart = if isMariaDB then ''
if ! test -e ${cfg.dataDir}/mysql; then
${mysql}/bin/mysql_install_db --defaults-file=/etc/my.cnf ${mysqldOptions}
touch /tmp/mysql_init
fi
'' else ''
if ! test -e ${cfg.dataDir}/mysql; then
${mysql}/bin/mysql_install_db --defaults-file=/etc/my.cnf ${installOptions}
${mysql}/bin/mysqld --defaults-file=/etc/my.cnf ${mysqldOptions} --initialize-insecure
touch /tmp/mysql_init
fi
Copy link
Contributor

Choose a reason for hiding this comment

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

this is slightly duplicated, why not do

preStart = 
let
  initCommand = if isMariaDB then ''
    ${mysql}/bin/mysql_install_db --defaults-file=/etc/my.cnf ${mysqldOptions}
  '' else "${mysql}/bin/mysqld --defaults-file=/etc/my.cnf ${mysqldOptions} --initialize-insecure";
in ''
  if ! test -e ${cfg.dataDir/mysql; then
    ${initCommand}
    touch /tmp/mysql_init
  fi
'';

Copy link
Member Author

Choose a reason for hiding this comment

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

As time goes by mariadb and mysql drift further apart so I figured in this case maybe just keep it separate in case there is more divergence... but yeah maybe it was a bit much and a bit premature.

Copy link
Contributor

Choose a reason for hiding this comment

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

As time goes by mariadb and mysql drift further apart so I figured in this case maybe just keep it separate in case there is more divergence...

That is a good point, this is probably fine if the actual conditional changes.

@worldofpeace
Copy link
Contributor

worldofpeace commented Mar 24, 2020

Lol, this is a cherry-pick. Didn't realize this right away (probably should read closer).

@flokli flokli merged commit 234bc36 into NixOS:release-20.03 Mar 24, 2020
@aanderse aanderse deleted the mysql80-backport branch March 24, 2020 23:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants