Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

devenv up exit with a 0 status code even if postgresql fails to start with an error #1680

Open
bbigras opened this issue Jan 21, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@bbigras
Copy link
Contributor

bbigras commented Jan 21, 2025

Describe the bug

If I run devenv up the command exits without any error message. It would be nice to have an error exit code and the ERR line from the log.

❯ cat /tmp/process-compose-bbigras.log
25-01-21 01:49:23.436 INF Process Compose v1.40.1
25-01-21 01:49:23.436 INF Loaded project from /nix/store/qkl8dwan1698nvg29q9p4p9x9m6w7yih-process-compose.yaml
25-01-21 01:49:23.436 INF Global shell command: bash -c
25-01-21 01:49:23.436 INF start UDS http server listening /run/user/1000/devenv-39e9b2d/pc.sock
25-01-21 01:49:23.436 ERR error="listen unix /run/user/1000/devenv-39e9b2d/pc.sock: bind: no such file or directory"

To reproduce

flake.nix

{
  description = "Description for the project";

  inputs = {
    devenv-root = {
      url = "file+file:///dev/null";
      flake = false;
    };
    flake-parts.url = "github:hercules-ci/flake-parts";
    nixpkgs.url = "github:cachix/devenv-nixpkgs/rolling";
    devenv.url = "github:cachix/devenv";
    nix2container.url = "github:nlewo/nix2container";
    nix2container.inputs.nixpkgs.follows = "nixpkgs";
    mk-shell-bin.url = "github:rrbutani/nix-mk-shell-bin";
  };

  nixConfig = {
    extra-trusted-public-keys = "devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw=";
    extra-substituters = "https://devenv.cachix.org";
  };

  outputs = inputs@{ flake-parts, devenv-root, ... }:
    flake-parts.lib.mkFlake { inherit inputs; } {
      imports = [
        inputs.devenv.flakeModule
      ];
      systems = [ "x86_64-linux" "i686-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];

      perSystem = { config, self', inputs', pkgs, system, ... }: {
        # Per-system attributes can be defined here. The self' and inputs'
        # module parameters provide easy access to attributes of the same
        # system.

        devenv.shells.default = {
          devenv.root =
            let
              devenvRootFileContent = builtins.readFile devenv-root.outPath;
            in
            pkgs.lib.mkIf (devenvRootFileContent != "") devenvRootFileContent;

          name = "my-project";

          imports = [
            # This is just like the imports in devenv.nix.
            # See https://devenv.sh/guides/using-with-flake-parts/#import-a-devenv-module
            # ./devenv-foo.nix
          ];

          # https://devenv.sh/reference/options/
          packages = [ ];

          process.managers.process-compose.settings.processes = {
            postgres.readiness_probe.exec.command = pkgs.lib.mkForce "pg_isready -h 127.0.0.1 -p 5432 -d template1";
          };

          services.postgres = {
            enable = true;
            listen_addresses = "127.0.0.1";
          };

        };

      };
      flake = {
        # The usual flake attributes can be defined here, including system-
        # agnostic ones like nixosModule and system-enumerating ones, although
        # those are more easily expressed in perSystem.

      };
    };
}

Version

devenv: 1.3.1 using flakes

@bbigras bbigras added the bug Something isn't working label Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant