Looking for feedback from @danbst, @thoughtpolice and @ocharles (as they are the currently listed postgresql maintainers) on the possibility of having the postgresql module options become more consistent with mysql module options.
Currently the mysql module has some great options like ensureDatabases and ensureUsers, but postgresql module does not.
I see several modules (like gitea, for example) create a postgresql user and database by adding relatively messy code to the preStart script, which then requires raised privileges. If the postgresql module had ensureDatabases and ensureUsers options like mysql did all this database code could be cleaned up and simplified greatly, and many modules wouldn’t require any privilege escalation at all in preStart. Plus, it is always nice to have different modules which do similar things have consistent options.
Has anyone considered doing this?
I have mixed feelings about this. But speaking of practice, if that kind of state management via declarative options works fine for MySQL usecase, why not use it for Postgresql?
I do myself create adhoc pg users and databases in
postStart script. So I can do review/merge if anybody want to implement that.
(But, as usual, - this kind of state management can be painful to maintain, if used outside of it’s usecase scope.)
@danbst thanks for the offer.
I have very limited experience with postgresql, so I would appreciate all the advice you can give me on my first attempt:
I slightly modified the redmine nixos test to use these new options and everything did seem to work as expected…
I’m looking very much forward to see support for
ensureUsers on postgresql - having database-type-specific setup code in other NixOS service modules seems messy (especially if the service might in theory support different database types).
@aanderse, could you open a PR with this branch, so people can start commenting on it?