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
experimental/multiple-mysqld-instances #5542
experimental/multiple-mysqld-instances #5542
Conversation
I think it's better to avoid this kind of import, it's hard to be accepted in nixos. I'm long thinking about multiple services, however right now I'm on vacation :) So this is my suggestion:
You can do this without the need for that kind of import. See nixos containers as an example. So Not only, we can think of an helper function |
I've sent a message to nix-dev so that it can be discussed. My patch is least invasive, your proposal is nicer in the long run so I agree on your idea. |
My proposal is not more invasive. Importing modules like in your approach is less declarative and probably more invasive. I think it's widely accepted that modules should not accept other arguments like that. |
Why won't you use nixos-containers? |
@jagajaga because one doesn't always need a container? I'm also interested in multiple services on the same machine without using containers. Containers are probably a good solution for distros like debian, but in nixos we have the possibility to run multiple services, and that's sometimes better in certain setups. |
@lethalman yeah, you are right, thx. |
@jagajaga I just proposed it, and it's a simple helper function |
@lethalman oops, missed it :) |
@lethalman can you give example how this would work, i'm trying to
|
@offlinehacker much like this PR, except that instead of importing the module you have |
What about services.mysqls.? Then we could stay backward compatible (services.mysql) |
This is related #5271 |
f806c26
to
896f6ef
Compare
This update implements .instances as supported by pierron, me, Eelco. Now that I understood that there is a use case for mysql.systemPackage I dropped the idea of using the shorter services.mysqls.name version. This also introduces resource tracking so that two mysql instances don't use same port or socket by accident. |
I will handle everything in service abstraction layer i'm working on.
|
I also don't like proposed solution, because it handles only very limited use case... |
Thing that bothers me the most is that interface for MySQL is now changed. I think it could be done without changing old interface. |
896f6ef
to
364e9f1
Compare
@offlinehacker I have a problem now. If you're ready with something better I'me fine. Till then I'd like to solve my problem (importing huge databases which is done fastest on tmpfs). @nbp I dropped the assertion. The case where it fails doesn't happen. I disagree though: I think assertions are just ways to make sure that below a line some properties hold. @offlinehacker In which way does the interface change for you? If you have a close look at the patch it should preserve the old interface because it takes into account services.mysql as well as services.instances.*. It just happens that services.mysql will get the same name as instances.mysql - thus you can use either old or new - but you'll run into problems using old and instances.mysql - because both will try to create a mysql user. |
@offlinehacker I think nixos doesn't solve all problems well - eg moving a live PHP project from one server to another cannot just be expressed in a configuration.nix file .. For this reason I wonder which is the most important task to work on. Still nixos/nixpkgs could be a starting point to get there. But that's a different story. |
Yeah you are kinda right, i must admit that i'm sometimes kinda angry on Actually your solution is pretty good, the only thing i don't like is how @offlinehacker https://github.com/offlinehacker I think nixos doesn't — |
I've opened an issue here with a proposal of mkMultiInstance and also a problem: #6784 |
…e times by accident. Example usage: config.resources.tcp-ports.80.required_by = "httpd Apache"; config.resources.tcp-ports.443.required_by = "httpd Apache SSL"; config.resources.uids.2000.required_by = "mysql user"; config.resources.gids.2000.required_by = "mysql user"; # you might have two mysql instances running using the same gid/uids: config.resources.uids.2000.allowCollisions = true; config.resources.gids.2000.allowCollisions = true;
Usage example: # traditional: services.mysql.enable = true; services.mysql.package = pkgs.mysql57; # add additional instance, eg on tmpfs mounted /tmp for developping: service.mysql.services.mysql_on_tmp = { enable = true; port = 3307; package = pkgs.mysql57; dataDir = "/tmp/mysql"; socketDir = "/tmp/mysql_tmpfs.socket"; uid = 20000; gid = 20000; };
364e9f1
to
dd1df4c
Compare
In case people are interested in a more immediate solution to this, you can use NixOS containers out of the box already and configure mysql instances inside of that, using the host networking, listening on a different port. I did that today and ran about 30 instances locally. |
As noted by @grahamc we just can't support running multiple services of everything we have in nixos modules, but you can do that using containers today. |
Allow instantiating multiple mysql instances.
Usage example of most current patch version: