-
-
Notifications
You must be signed in to change notification settings - Fork 15.4k
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
nixos/mysql: declarative users & databases #29387
Conversation
using Unix socket authentication, ensured on every rebuild.
👍 Looks good, thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I did not yet test it on a system with existing DBs and users but will try to to that later today.
Works exactly as expected 👍
Thanks! |
I don't use MySQL, but I've stumbled on this:
I think it's a bit flaky check. What if I use |
@danbst you're totally right, did not think about that case. Your proposal with parseDrvName sounds much better, and should be a drop-in replacement for the current condition. Do you want to pose the PR, or should I do it? |
This is cool. I'm going to use this in #31475 instead of the stateful workaround I have now. |
@ravloony thank you! Yes, looks like a good fit. And more usage examples in NixOS services apart from mysql-backup will probably help more people discovering and adopting this. 😄 |
@florianjacob Done. Feel free to have a look and see if there is anything I could do better. |
using Unix socket authentication, ensured on every rebuild.
Motivation for this change
I want to be able to declaratively manage the MySQL / MariaDB databases and users I need for the standard web apps like wordpress, nextcloud, piwik et cetera. This can be used by end users as well as package maintainer.
This helps #29031 by allowing to easily create a MySQL user for backing up, with reduced permissions.
This goes in the direction of and could supersede #6963 , but with scope reduced to local, Unix socket authenticated users.
I tried to circumvent the issue of un-synchronized state between nix configuration and actual databases by calling this ensureDatabases / ensureUsers and making it clear that this only ensures the databases and users are there, but does nothing to delete or rename databases and users or to reduce permissions that were once given. This will be up to the user, to prevent e.g. accidental deletion of databases and generally breaking things.
(Also, I don't even know how the state of which databases existed before and after rebuilds could be diffed and updated accordingly.)
Things done
build-use-sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)