Any roadmap to support multiple instances?

I came across to [1]. And I understand this may not be available in the near future; however I am still very curious. Do the nix team have any plans to support multiple instances?

I have similar requirement. My use case is I participate in several projects. Some of them share the same tech stacks, such as Kafka, Postgres, and so on. So they have issues such as port collision. Though there are workaround, it’d be nice if a user can purely use the nix env without docker.

Nonetheless, thank you for providing this amazing software.

[1]. Can nix module support multiple instance?

2 Likes

While I’m by no means authorative on this, I doubt it. It’d take a lot of effort to rewrite all modules, it’d take a fair bit of effort to evaluate which can even support multiple simultaneous instances on one OS, and it’s impossible to do generically.

The modules are mostly maintained by volunteers, the modules that do support multiple instances usually do because it was the most natural way to write them; If you’re interested in making this happen for specific modules, you should probably make the changes and try to upstream them instead of hoping someone will step in.

Your best bet in general probably remains nixos containers, or GitHub - cloudwatt/nix-container-images: Write container images as NixOS machines if you prefer docker. Those technologies were basically designed to solve the problems you’re facing.

2 Likes

Generally speaking NixOS modules which support multiple instances have more complicated code then modules which do not. In my opinion we should not rewrite modules to support multiple instances unless there is a large benefit to do so. I hope instead the module system can change in some way (like edolstra suggested several nixcons ago) to more naturally support multiple instances.

5 Likes

Do you have link to Edolstra’s talk? There are several links I find on the internet, it’s about Flakes. Is it the one you mentioned? Thank you for the input!

1 Like

Sorry I don’t have a link to the talk… but I have a link to his notes he went through during the talk: https://gist.github.com/edolstra/29ce9d8ea399b703a7023073b0dbc00d#nixos-services

1 Like

These slides are way less helpful than @aanderse’s link but adding it anyway for posterity:

In case someone is looking for concrete examples on workarounds, @danbst was super helpful in this thread:

… and putting this here for posterity: Nixpkgs issue #2660