devenv
devenv copied to clipboard
Allow services to be docker containers to ease migrating to devenv
Context: A codebase I'm working on had mongo, postgresql, and localstack. Mongo and postgres already existed as services.
I was about to add localstack, but realized that we use an older version that nixpkgs currently has. It's probably still worth adding, but it made me realize how quickly I could have a proof of concept for devenv if it gave an easy way for running docker containers as services.
workaround: docker run ...
in enterShell is what I'll probably do for now.
You can use 'docker run' and 'docker rm -f', if you use process-compose as the implementation for the services. Check the process-compose readme for examples. I use this extensively already for hard to package things.
Relevant to #2
We could have something like
{
services.container.foobar.image = "postgres:14";
}
That would run the docker
or some other container tech to run the container.
We could have something like
{ services.container.foobar.image = "postgres:14"; }
That would run the
docker
or some other container tech to run the container.
That sounds good and is what I envisioned, but I haven't yet checked out the process-compose example the other user mentioned so I'm not sure how it compares.
Just an example for any future people who wander upon this,
processes.postgres = {
exec = ( lib.concatStringsSep " " [
"${pkgs.docker}/bin/docker"
"--name postgres"
"run"
"-p 5432:5432"
"postgres"
]
);
process-compose = {
description = "docker container of postgres";
shutdown = {
command = "${cfg.package}/bin/docker rm -f postgres";
};
};
};