Announcing services-flake

I’d like to announce a new open-source project from Juspay called services-flake. It allows defining and running services in your project flakes, and works on both Linux and macOS . We internally use it in various projects at Juspay.

Features

  • services-flakes is based on flake-parts, which brings the NixOS module system to flakes and that heavily simplifies the DX while editing Nix.

    • Thus, you can share your services across projects (see the Nammayatri blog post below for an example)
  • It works on both Linux and macOS and runs services natively (configured in Nix) without using emulation

  • You can define multiple services of the same type

  • We have a native testing infrastructure that you can use to test your services both locally and in CI (pure Nix builds)

We are pretty happy at how it has shaped up so far. There’s room for improvement, and we’re open to any feedback you’ve got.

See Also

32 Likes

Looks interesting.
Maybe it would make sense to unify this three projects a bit?
We have now at minimum three projects doing the same thing.

1 Like

Cool! What’s the difference with Devenv?

The README has a comparison, currently only against devenv.sh.
I think another contender would be numtide/devshell, which is more open to use as a component (unlike devenv), but doesn’t provide ready-to-use services.
Arion does something similar for docker-compose instead of process-compose, but also not a library of services, and no flake-parts module yet.

3 Likes
1 Like

services-flake 0.2.0 is out!

2 Likes

Looks awesome! Is use-case for this tool is to only run local development services or also to deploy to “production”?

It is for local development and CI.

Especially because we can define the services once and reuse everywhere else, it opens up possibilities like being able to import these configurations into other set of process groups. These other sets could be doing anything, like one of them could be running load-test on your application, another could be running integration-tests, etc.

1 Like

services-flake 0.3.0 is out!

4 Likes

I was trying to write my own service as a module, adhering to this format, to be used in the same flake, but I was having a hard time finding any documentation on how to do so…
I can see that you guys basically translate the YAML configuration into an attribute sets, but would be grateful for more detailed docs.
Also, I noticed the lib.multiService utility, but since I’m rather new to modules I’m struggling to find a way to make use of it for my own services… Again, would appreciate better docs on service writing rather than consuming!

Does this help: Custom service – services-flake ?

1 Like

Awesome stuff, thanks!

I was originally trying to do my service using services-flake as template, but was getting issues (I think flake show was saying that the check set was not a derivation or something), so I searched some more and found the passetto service, and that did work but couldn’t get it to multiservice.
The added explanation of the difference made it clear why that was the case!

So yeah, the document was basically exactly the process I went thru but explained the right way!

Now I’m trying to configure my service to have some state outside the store, but I think that’s outside the scope of this module :slight_smile:

If I may have a feature request, it would probably be some sort of “migration” function to docker/docker-compose/helm, perhaps I’ll work on that if I really want that feature and expose it as a module, since I’d like to use process-compose locally but deploy containers since that’s supported the most.

Again, thank you so much for the doc!

1 Like

If I may have a feature request, it would probably be some sort of “migration” function to docker/docker-compose/helm

This is an interesting idea. It probably is in line with something I want to implement/collaborate with someone on: “Portable service layer”. The idea originated after Question: How to use `systemd.service` ? · Issue #239 · juspay/services-flake · GitHub, but turns out there was already a draft for something similar in nixpkgs.

This is what I think the future for services would look like:

Option definitions will lie in nixpkgs along with config for systemd service, which it already does, but won’t be as tightly coupled after “Portable service layer” is implemented. services-flake can then re-use the options from nixpkgs, and output configs for multiple targets, like: lanuchd, process-compose or as you mentioned docker/docker-compose/helm. Thus, we will have uniformity in option definitions no matter what the underlying service management mechanism one uses.

1 Like