cachix / devenv

Fast, Declarative, Reproducible, and Composable Developer Environments
https://devenv.sh
Apache License 2.0
3.56k stars 259 forks source link

Run processes in the background #80

Closed JanLikar closed 1 month ago

JanLikar commented 1 year ago

It would be nice to have a way of running processes in the background, similar to docker-compose up -d.

Maybe devenv up -d would be an intuitive choice?

domenkozar commented 3 months ago

That's implemented in #745

ElrohirGT commented 2 weeks ago

Hi @domenkozar ! I tried reading the link you mentioned, it took me to a python rewrite and then to a rust rewrite. I'm using devenv as a flake but when I tried running the command devenv up -d as the original author suggested it still runs as normal with a TUI and everything. How could I run services in a detached state?

domenkozar commented 2 weeks ago

It does not work with flakes yet.

ElrohirGT commented 2 weeks ago

Hi! I found a solution for my use case and I'm sharing it here in case someone else ends here. I wanted to run "devenv up" in CI from a github action to automatically setup postgress and other background services of my project. Turns out the default TUI of process-compose was the problem so searching on the documentation I managed to add the following configuration:

default = devenv.lib.mkShell {
          inherit inputs pkgs;
          modules = [
            {
              process = {
                process-compose = pkgs.lib.mkOptionDefault {
                  tui = "false";
                };
              };

              services.postgres = {
                enable = true;
                listen_addresses = postgresHost;
                port = postgresPort;
                initialScript = dbInitFile;
              };
            }
          ];
        };

pkgs.lib.mkOptionDefault overrides only the field tui inside the configuration that process-compose uses.