Home

Awesome

Dark

This is the main repo for Darklang-classic, a combined language, editor, and infrastructure to make it easy to build backends.

This repo is intended to help Dark users solve their needs by fixing bugs, expanding features, or otherwise contributing. Dark is source available, not open source.

This is not under active development, see instead the dark repo.

Ceasefire Now

See also:

See our guide to the repo for help browsing.

Contributing

We are committed to make Dark easy to contribute to. Our contributor docs will help guide you through your first PR, find good projects to contribute to, and learn about the code base.

Getting started

We try to make it really easy to get started. If you have any problems, please ask in Discord and we'll work to fix any issues you have.

Install dependencies

We develop Dark within a docker container, so there is not a lot of setup. However, we do need to setup the host system in a few ways to support running scripts, and Docker.

OSX

To build and run the server you must have the following installed (and running):

Linux

Everything should just work on Linux, so long as you have docker installed and you are using bash 4 or later.

Windows

On Windows, you can run Dark in WSL2 (Windows Subsystem for Linux):

Building and running for the first time

Running the build script

Now that the pre-requisites are installed, we should be able to build the development container in Docker, which has the exact right versions of all the tools we use.

These steps apply for all builds, VSCode or using scripts/builder:

Using Dark scripts

The scripts/ directory is full of scripts. They automatically execute in the dev container, even if they are run on the host (see scripts/devcontainer/_assert-in-container for how this works). Scripts starting with an underscore are primarily intended to be run by other scripts. Scripts without an underscore are usually intended to be called by a human, though they are often also called by other scripts as well.

Read the contributor docs

If you've gotten this far, you're now ready to contribute your first PR.

Advanced setup

Testing

Unit tests run when you specify --test to scripts/builder. You can run them as a once off using:

Integration tests:

You can also run integration tests on your (host) machine, which gives you some debugging ability, and typically runs faster:

There are good debugging options for integration testing. See integration-tests/README.md.

Running unix commands in the container

Accessing the local db

Config files

Config files (config/) define all env vars that you can use in Dark code. All config vars must start with DARK_CONFIG. Changing a config variable in config/dev requires restaring the devcontanier.

Debugging the client

You can enable the FluidDebugger by mousing over the Gear in the left-sidebar. There is also "Enable debugger" which enables a legacy debugger that nobody uses and doesn't work well.

If you're using Chrome, enable Custom Formatters to see ReScript values in Chrome Dev Tools instead of their JS representation. From within Chrome Dev Tools, click "⠇", "Settings", "Preferences", "Enable Custom Formatters".

Debugging dotnet

Debugger

The VSCode debugger works out of the box with Dark, supporting stepping, breakpoints, inspecting the stack, etc. You must launch the executable from VSCode for this to work--attaching does not currently seem to work. You can edit launch.json to change what tests are run or how other binaries are started up, which should be straightforward.

REPL (fsi)

You can get a REPL with all of the Dark libraries loaded by running:

Segfaults and crashes

When dotnet crashes, you can debug it by running:

In LLDB, you can use dotnet's SOS plugin to read the stack, values, etc. The plugin is automatically loaded in lldb in the dev container.

Production Services

The app is split into backend and client/. Part of the backend is used in the client (Wasm).

These are compiled to create libraries and binaries.

These are put into containers, whose definitions are in containers/. We also have some containers which are defined entirely in their directory (typically, these have a self-contained codebase).

The containers are deployed via Kubernetes. A group of containers are deployed together, which is called a pod. Those pods, and how they are run (for example, how many of them, what secrets they have access to, how to check if they are still alive) are defined by a set of Yaml files which is called a deployment. Our deployments are all defined in the services directory.

A service in our repo typically wraps a deployment, but it can sometimes mean other things, so we also have a number of other services, defined via yaml files, in services. Some of the services are deployments that use 3rdparty containers (eg, "Let's Encrypt"), and some are abstractions around Google Cloud services.

Other important docs

Less important docs