6. Dependencies

Reference: {#DevDeps}

This page documents how to install necessary dependencies to work with the wire-server code base.

6.1. General package dependencies (needed to compile Haskell services)

Note: all the below sections for getting compile-time dependencies necessary to compile all of wire-server may potentially go out of date; if you spot a mistake please open an issue or PR

6.1.1. Nix + Direnv

  1. Install Nix. macOS users with a recent Mac and non-NixOS Linux users should follow these instructions to install a binary distribution of Nix.

    Debian users (running at least Debian 11) can use this distro’s nix-bin package. In this case, ensure your user is added to the nix-users group (and restart your login session to pick this up). Note that Debian’s Nix package provides a multi-user installation (as opposed to a single-user installation, which is an option when using the binary distribution tarball).

  2. Add the wire-server Cachix cache to your system. On NixOS, this can be done by adding the following snippet to your system configuration:

      nix.binaryCachePublicKeys = [ "wire-server.cachix.org-1:fVWmRcvdsqzKek3X5Ad8nYNsBSjKZ9Um2NMLfMLS77Y=" ];
      nix.binaryCaches = [ "https://wire-server.cachix.org" ];

    On non-NixOS systems, these need to be manually added to your nix.conf (this is at ~/.config/nix/nix.conf for single-user installations, and /etc/nix/nix.conf for multi-user installations; you can create this file if it doesn’t exist):

    substituters = https://cache.nixos.org https://wire-server.cachix.org
    trusted-public-keys = wire-server.cachix.org-1:fVWmRcvdsqzKek3X5Ad8nYNsBSjKZ9Um2NMLfMLS77Y= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
  3. Install Direnv. On Debian, you can install the direnv package. On MacOS use brew install direnv.

    • Make sure direnv is hooked into your shell via its appripriate rc file. Add eval "$(direnv hook bash|zsh|fish)" to your ~/.(bash|zsh|fish)rc .

    On NixOS with home-manager, you can set programs.direnv.enable = true;, which does all of the above.

    See the Installation documentation for further details.

    When successfully installed and hooked, direnv should ask you to direnv allow the current .envrc when you cd to this repository.

  4. As this repo uses git submodules, ensure you’re fetching from them automatically. Run git config --global submodule.recurse true to enable this globally. Run git config --global fetch.parallel 10 to fetch more submodules in parallel. If you’ve already cloned this repo before having enabled this, run git submodule update --init --recursive once. Stack’s Nix Integration

Using Stack’s Nix integration, Stack will take care of installing any system dependencies automatically - including cryptobox-c. If new system dependencies are needed, add them to the stack-deps.nix file in the project root.

6.1.2. Fedora:

sudo dnf install -y pkgconfig haskell-platform libstdc++-devel libstdc++-static gcc-c++ libtool automake openssl-devel libsodium-devel ncurses-compat-libs libicu-devel libxml2-devel snappy-devel protobuf-compiler

6.1.3. Ubuntu / Debian:

Note: Debian is not recommended due to this issue when running local integration tests: #327. This issue does not occur with Ubuntu.

sudo apt install pkg-config libsodium-dev openssl-dev libtool automake build-essential libicu-dev libsnappy-dev protobuf-compiler libxml2-dev zlib1g-dev libtinfo-dev liblzma-dev libpcre3 libpcre3-dev -y

If openssl-dev does not work for you, try libssl-dev.

6.1.4. Arch:

# You might also need 'sudo pacman -S base-devel' if you haven't
# installed the base-devel group already.
sudo pacman -S snappy icu openssl ncurses-compat-libs

6.1.5. macOS:

brew install pkg-config libsodium openssl automake icu4c snappy protobuf

Note: macOS users will need to make sure to link Haskell services against a more recent version of OpenSSL than what ships with the OS by default. Additionally, icu4c is installed in a non-standard location by homebrew. Add the following to your .stack/config.yaml:

- /usr/local/opt/openssl/include
- /usr/local/opt/icu4c/include

- /usr/local/opt/openssl/lib
- /usr/local/opt/icu4c/lib

Note: if you’re getting fatal error: 'libxml/parser.h' file not found and you’re on macOS Mojave, try doing:

sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /

6.2. Haskell Stack

Please refer to Stack’s installation instructions.

When you’re done, ensure stack --version is the same as STACK_VERSION in build/ubuntu/Dockerfile.prebuilder.

If you have to, you can downgrade stack with this command:

stack upgrade --binary-version <version>

6.2.1. Ubuntu / Debian

Note: The packaged versions of haskell-stack are too old. It is recommended to follow the generic instructions or to use stack to update stack (stack upgrade).

sudo apt install haskell-stack -y

6.2.2. Generic

curl -sSL https://get.haskellstack.org/ | sh
# or
wget -qO- https://get.haskellstack.org/ | sh

6.3. Rust

6.3.1. Ubuntu / Debian

sudo apt install rustc cargo -y

6.3.2. Generic

curl https://sh.rustup.rs -sSf | sh
source $HOME/.cargo/env

6.4. Formatting Haskell files

You need ormolu on your PATH, get it with stack install ormolu

6.5. Generating license headers

We use headroom, get it with stack install headroom

6.6. cryptobox-c

6.6.1. Ubuntu / Debian

git clone https://github.com/wireapp/cryptobox-c && cd cryptobox-c
make dist
dpkg -i target/release/cryptobox*.deb

6.6.2. Generic

export TARGET_LIB="$HOME/.wire-dev/lib"
export TARGET_INCLUDE="$HOME/.wire-dev/include"
mkdir -p "$TARGET_LIB"
mkdir -p "$TARGET_INCLUDE"
git clone https://github.com/wireapp/cryptobox-c && cd cryptobox-c
make install

# Add cryptobox-c to ldconfig
sudo bash -c "echo \"${TARGET_LIB}\" > /etc/ld.so.conf.d/cryptobox.conf"
sudo ldconfig

Make sure stack knows where to find it. In ~/.stack/config.yaml add:

(using ~ or $HOME doesn’t work, needs full paths)

- /usr/local/include
- <YOUR_HOME_DIR>/.wire-dev/include

- /usr/local/lib
- <YOUR_HOME_DIR>/.wire-dev/lib

6.7. Docker

Note: While it is possible to use non-docker solutions to set up and configure this software, we recommend using docker and our provided docker images to configure dependent services rapidly, and ensure a consistent environment for all potential developers.

6.7.1. Ubuntu / Debian Testing/Unstable:

sudo apt install docker.io docker-compose

After installing docker-io, add your user to the docker group, and restart your shell (usually involving a restart of your graphical environment).

once you’ve logged in again, if you would like to upload any docker images (optional):

docker login --username=<MY_DOCKER_USERNAME>

6.7.2. Generic:

6.8. Telepresence

You can instead use telepresence to allow you to talk to services installed in a given kubernetes namespace on a local or remote kubernetes cluster using easy DNS names like: curl http://elasticsearch:9200.


  • install telepresence (e.g. nix-env -iA nixpkgs.telepresence)

  • you need access to a kubernetes cluster

  • you need a namespace in which you have installed something (e.g. make kube-integration-setup will do this)

6.8.1. Telepresence example usage:

# terminal 1
telepresence --namespace "$NAMESPACE" --also-proxy cassandra-ephemeral

# terminal 2
curl http://elasticsearch-ephemeral:9200

6.8.2. Telepresence example usage 2:

# just one terminal
telepresence --namespace "$NAMESPACE" --also-proxy cassandra-ephemeral --run bash -c "curl http://elasticsearch-ephemeral:9200"

6.8.3. Telepresence usage discussion:

  • If you have fake-aws and databases-ephemeral helm charts set up, you can run either brig and other services locally (they connect to cassandra-inside-kubernetes)

  • If you also have brig and other haskell services running in kubernetes (e.g. you ran make kube-integration-setup, you can use telepresence to only run test executables (like brig-integration) locally which connect to services inside kubernetes.

In both cases, you need to adjust the various integration configuration files and names so that this can work.

6.9. Helm chart development, integration tests in kubernetes

You need kubectl, helm, helmfile, and a valid kubernetes context. Refer to https://docs.wire.com for details.