juspay / services-flake

NixOS-like services for Nix flakes
https://community.flake.parts/services-flake
MIT License
369 stars 31 forks source link

docs(example): add share-services #137

Closed shivaraj-bh closed 7 months ago

shivaraj-bh commented 7 months ago

Run services:

nix run "github:juspay/services-flake/share-services?dir=example/share-services"

Run integration-test:

nix run "github:juspay/services-flake/share-services?dir=example/share-services"#integration-test
srid commented 7 months ago

2. Instead of running empty pg1 and r1, what if we had something equally demo-worthy as example/simple (which shows pgweb)?

Perhaps we can just clone example/simple and refactor it. Viz., put the northwind db service in example/share-services/database/flake.nix:

https://github.com/juspay/services-flake/blob/961bfd3ff8177fd0a0e625d7c6e37b9a11259fb0/example/simple/flake.nix#L30-L39

And then use it, for running pgweb, from example/share-services/frontend/flake.nix:

https://github.com/juspay/services-flake/blob/218fa6cc9a875c20def622e974fb4e0f391b3b6d/example/flake.nix#L49-L57

? That's one idea.

Interestingly, in future we can create another example to demonstrate creation of new services, by refactoring this pgweb into its own service (services.pgweb.pgservice = config.services.postgres.pg1).

shivaraj-bh commented 7 months ago

@srid I have so far implemented this. Although, I am not super pleased with the way services.nix is being used between databases and frontend, any suggestions?

srid commented 7 months ago

any suggestions?

I'll take a look. I just added a justfile command to run the new example, and I noticed this despite the sockerDir option:

image

Bug somewhere?

shivaraj-bh commented 7 months ago

Its not a bug, data will still remain in pwd, only the socket will be created elsewhere. Hence, the options, dataDir and socketDir are different.

shivaraj-bh commented 7 months ago

Also, if we move the northwind DB to share-services example, would it make sense to have a much simpler example in simple?

srid commented 7 months ago

Also, if we move the northwind DB to share-services example, would it make sense to have a much simpler example in simple?

Simple, as in ?

srid commented 7 months ago

@shivaraj-bh These files seem out of place; were they added by accident?

image

srid commented 7 months ago

n/m - that's just old code in the PR.

shivaraj-bh commented 7 months ago

Also, if we move the northwind DB to share-services example, would it make sense to have a much simpler example in simple?

Simple, as in ?

n/m, I was thinking of just having

services.postgres.pg.enable = true;
services.redis.r1.enable = true;

But such simple cases are anyways covered in the "Getting started" section of the service documentation.

srid commented 7 months ago

Good enough, we can always improve our examples later, and add more of them. I'll merge, and flip the branch name in main.