Inquiry about Dev Container Support in VSCode on Project IDX

Hello,

I am currently using Project IDX for my development needs and I have been enjoying the features it offers. However, I have a specific requirement regarding development environments.

I am interested in utilizing VSCode dev containers within the Project IDX environment. Dev containers are essential for my workflow as they allow for consistent development environments, which is critical for my projects.

Could you please provide information on the following:

  1. Is there existing support for using VSCode dev containers within Project IDX?
  2. If not, are there any plans to integrate this feature in the near future?
  3. Are there any workarounds or alternative solutions you would recommend for achieving a similar development setup within Project IDX?

Thank you in advance for your assistance. I look forward to your response.

Hi Mateusz,

We currently don’t support dev containers and instead provide Nix-based dev environment configuration where you can specify tools, applications, libraries that you need to compile and run your application. We currently provide the basics like installing packages, vscode extensions, configuring previews and enabling docker with services.docker.enable = true but plan to add more configured services out of the box. Please give it a try.

To help us improve, can you share what your dev container requirements are, what services you need to run and tools you install in the container(s)?

Hi,

Thank you for the detailed response. I appreciate the information about the Nix-based dev environment configuration. I believe I can adapt my solution using Nix definitions, but I have a couple of specific questions:

  1. Event Hooks: In dev containers, we use postCreate and postAttach scripts to automate certain setup tasks after the container is created or attached. Could you please clarify if there are equivalent events or hooks available in your environment? If so, how can I configure them to achieve similar automation?
  2. Script Execution: What is the recommended approach for running custom scripts during the setup phase in your Nix-based environment? I typically use these scripts to install additional dependencies, configure environment variables, and perform other setup tasks.
  3. Example Configuration: If possible, could you provide an example or documentation reference that demonstrates how to implement these hooks or similar logic in the Nix environment? This would greatly help in transitioning our current dev container setup to your platform.

Thank you for your assistance. I look forward to your response.

Best regards, Mateusz

Hi @Mateusz_Rybicki ,

  1. We do have support for onCreate and onStart hooks with Nix
  2. You can definitely add packages to install with your dev.nix file.
  3. You can explore example configurations through our template gallery which includes a wide variety of dev.nix configurations. Also, see below for a sample dev.nix file with comments for documentation:
# To learn more about how to use Nix to configure your environment
# see: https://developers.google.com/idx/guides/customize-idx-env
{ pkgs, ... }: {
  # Which nixpkgs channel to use.
  channel = "stable-23.11"; # or "unstable"
  # Use https://search.nixos.org/packages to find packages
  packages = [
    pkgs.nodejs_20
    pkgs.python3
  ];
  # Sets environment variables in the workspace
  env = {};
  idx = {
    # Search for the extensions you want on https://open-vsx.org/ and use "publisher.id"
    extensions = [
      "angular.ng-template"
    ];
    workspace = {
      # Runs when a workspace is first created with this `dev.nix` file
      onCreate = {
        npm-install = "npm install --no-audit --prefer-offline";
      };
      # To run something each time the workspace is (re)started, use the `onStart` hook
      onStart = {
        hello = "echo Hello IDX!";
      };
    };
    # Enable previews and customize configuration
    previews = {
      enable = true;
      previews = {
        web = {
          command = ["npm" "run" "start" "--" "--port" "$PORT" "--host" "0.0.0.0" "--disable-host-check"];
          manager = "web";
        };
      };
    };
  };

  # Start docker daemon
  services.docker.enable = true;
}