Skip to content

Basic usage of devShell #483

@peedrr

Description

@peedrr

TL;DR: Is it always necessary to nix run before opening a dev shell?

Firstly, thank you! My stack is Postgres, Redis and Nats, so it looks like I'm well covered straight out of the box.

I'm right at the beginning of my journey with services-flake so please excuse the "page 1" question! (And I'm only on about page 2 with flakes!)

The flake gets loaded by direnv

Here's my flake so far:

{
  description = "Testing services-flake with Redis";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";

    # services-flake
    process-compose-flake.url = "github:Platonic-Systems/process-compose-flake";
    services-flake.url = "github:juspay/services-flake";
    flake-parts.url = "github:hercules-ci/flake-parts";
  };

  outputs = inputs:
    inputs.flake-parts.lib.mkFlake { inherit inputs; } {
      imports = [
        # import the flake module
        inputs.process-compose-flake.flakeModule
      ];
      systems = inputs.nixpkgs.lib.systems.flakeExposed;
      perSystem = { pkgs, config, ... }: {
        # Create the process-compose configuration, importing services-flake
        process-compose."default" = {
          imports = [
            inputs.services-flake.processComposeModules.default
          ];
          # Define the services to be started
          services = {
            redis."r1".enable = true;
          };
        };

        # DevShell
        devShells.default = pkgs.mkShell {
          inputsFrom = [
            config.process-compose."default".services.outputs.devShell
          ];
        };
      };
    };
}

When I cd into the directory I seem to already have packages, e.g. redis-cli, but redis-server is not running:

$ redis-cli
Could not connect to Redis at 127.0.0.1:6379: Connection refused
not connected>

Obviously nix run then gives me Process Compose. Opening another shell to the same directory then allows me to connect to the Redis server. Is this the intended usage? Is it possible to nix develop and then start Process Compose as needed? (Without typing nix run?)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions