This documentation provides a comprehensive guide to configuring the development environment for the sourcegraph/zoekt project. The focus is on settings and options within the development setup, utilizing Go, shell, Nix, and Dockerfile.

Go Module Configuration

The sourcegraph/zoekt project uses Go modules for dependency management. When working with Go, the module name is specified as follows:

module github.com/sourcegraph/zoekt

This translates to the Go build output being relative to this module path. It is essential to avoid using the -mod=vendor option, as it is not needed in this setup.

Shell Configuration

Environment variables are key in controlling many aspects of the build and run-time operations in zoekt. They can be set in your shell configuration. Here are some important variables:

  • ZOEKTD_ADDR: The address on which the zoekt server listens.

Example of setting the environment variable in a shell configuration file (e.g., ~/.bashrc or ~/.zshrc):

export ZOEKTD_ADDR=:3270

To apply the configuration, source the file:

source ~/.bashrc

Nix Environment Configuration

If you are using Nix for managing development dependencies, ensure your default.nix file is properly configured. An example configuration might look like this:

{ pkgs ? import <nixpkgs> {} }:

pkgs.stdenv.mkDerivation {
  pname = "zoekt";
  version = "1.0.0";

  src = pkgs.fetchFromGitHub {
    owner = "sourcegraph";
    repo = "zoekt";
    rev = "v${version}";
    hash = "sha256-...";
  };

  buildInputs = [ pkgs.go ];

  installPhase = ''
    mkdir -p $out/bin
    go build -o $out/bin/zoekt ./cmd/zoekt
  '';
}

In this example, replace "sha256-..." with the actual hash of the fetched source.

Docker Configuration

For developers utilizing Docker, it is important to set up a Dockerfile for the development environment correctly. A simple Dockerfile for zoekt could look like this:

FROM golang:1.17

WORKDIR /go/src/github.com/sourcegraph/zoekt

COPY . .

RUN go get -d ./...

CMD ["go", "run", "./cmd/zoekt"]

To build the Docker image, run:

docker build -t zoekt-dev .

This command creates a Docker image named zoekt-dev based on your configurations and the local source code.

Running the Development Server

To start the development server, ensure that your environment is configured correctly, and run the following command within the project directory:

go run ./cmd/zoekt

This command launches the zoekt server, listening to the address specified by the ZOEKTD_ADDR variable.

Conclusion

In summary, configuring the development environment for sourcegraph/zoekt involves setting appropriate environment variables, utilizing Nix for dependency management, and creating an effective Dockerfile. Proper setup ensures a smooth development experience while working with the zoekt codebase.

All configuration settings should reflect the nuances of your system and development preferences. For specific commands and further details, always refer to the internal documentation associated with the repository.

Source: GitHub repository sourcegraph/zoekt