Can nix module support multiple instance?

is there a way to support multiple instance for service module?
nixos-container maybe is a solution. but it’s will need a extra network layer to setup.

The individual modules you’re looking at would need to be rewritten to support multiple instances, generally speaking. For now containers are likely your best bet. What service(s) did you have in mind?

thanks, i’ll take the container way for now.

just want to test the cluster/replication/logicical-system-isolated mode for different database on local node for dev purpose and scripting.

such as: kafka, elasticsearch, postgresql, cassandra, minio…

Unfortunately the situation is containers for now then. On the plus side containers are going to better simulate reality though.

Good luck!

network for containers is optional

containers.config.services.postgresql.enable = true; and services.postgresql.enable = true; are almost identical from user POV. Just make sure ports don’t clash.

Does anyone know where to look to see an example of a service in a container done it in configuration? I’d love to do this, but the devil is in the details…

thanks.
sometimes i use mac to test and develop.
the mac don’t support nixos-container as it depend on machinectl.
but i can run nix module on all platform by systemd and launchpad.

i have created my first nix package recently, bee.

it’s a p2p distributed storage service, and due to its design the proper way to provide more storage to the world is to run more executables.

can someone point me to an example service that i could look at and copy? i have a vague idea how to do it, but i’m still new to nix, and i would much rather adapt something than finding my way on my own.

openvpn is the first that comes to mind.

thanks for the openvpn suggestion, it has helped to get an idea!

FTR, i have opened a (draft) PR with my implementation: DRAFT bee: make it able to start n instances by attila-lendvai · Pull Request #113940 · NixOS/nixpkgs · GitHub