Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
env=$(nix-build --no-out-link "$PWD/direnv.nix")
PATH_add "${env}"

# allow local .envrc overrides
[[ -f .envrc.local ]] && source_env .envrc.local
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ libzauth:
.PHONY: hie.yaml
hie.yaml: stack-dev.yaml
stack build implicit-hie
stack exec gen-hie | nix-shell --command 'yq "{cradle: {stack: {stackYaml: \"./stack-dev.yaml\", components: .cradle.stack}}}" > hie.yaml'
stack exec gen-hie | yq "{cradle: {stack: {stackYaml: \"./stack-dev.yaml\", components: .cradle.stack}}}" > hie.yaml

.PHONY: stack-dev.yaml
stack-dev.yaml:
Expand Down
1 change: 1 addition & 0 deletions changelog.d/5-internal/direnv_buildEnv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Replace shell.nix with direnv + nixpkgs.buildEnv based setup
21 changes: 16 additions & 5 deletions shell.nix → direnv.nix
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,21 @@ let

binPath = "client/bin/kubectl";
};

kind = staticBinary {
pname = "kind";
version = "0.11.0";

darwinAmd64Url = "https://github.com/kubernetes-sigs/kind/releases/download/v0.11.1/kind-darwin-amd64";
darwinAmd64Sha256 = "432bef555a70e9360b44661c759658265b9eaaf7f75f1beec4c4d1e6bbf97ce3";

linuxAmd64Url = "https://github.com/kubernetes-sigs/kind/releases/download/v0.11.1/kind-linux-amd64";
linuxAmd64Sha256 = "949f81b3c30ca03a3d4effdecda04f100fa3edc07a28b19400f72ede7c5f0491";
};
};
in pkgs.mkShell {
name = "shell";
LOCALE_ARCHIVE = "${pkgs.glibcLocales}/lib/locale/locale-archive"; # works around https://github.com/tweag/ormolu/issues/38
buildInputs = [
in pkgs.buildEnv {
name = "wire-server-direnv";
paths = [
pkgs.docker-compose
pkgs.gnumake
pkgs.haskell-language-server
Expand All @@ -107,11 +117,12 @@ in pkgs.mkShell {

# To actually run buildah on nixos, I had to follow this: https://gist.github.com/alexhrescale/474d55635154e6b2cd6362c3bb403faf
pkgs.buildah
pkgs.kind

pinned.stack
pinned.helm
pinned.helmfile
pinned.kubectl
pinned.kind
];
}

5 changes: 3 additions & 2 deletions docs/developer/dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,12 @@ docker login --username=<MY_DOCKER_USERNAME>
* [Install docker](https://docker.com)
* [Install docker-compose](https://docs.docker.com/compose/install/)

## Nix
## Nix + Direnv

Using Stack's [Nix integration](https://docs.haskellstack.org/en/stable/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.
Just type `$ nix-shell` and you will automatically have `make`, `docker-compose` and `stack` in `PATH`.

If you have `direnv` and `nix`, you will automatically have `make`, `docker-compose` and `stack` in `PATH` once you `cd` into the project root and `direnv allow`.
You can then run all the builds, and the native dependencies will be automatically present.

## Telepresence
Expand Down
10 changes: 10 additions & 0 deletions docs/developer/editor-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ Install the [projectile][] package for Emacs and do `M-x projectile-add-known-pr
ad-do-it)))
```

### Haskell Language Server

To use HLS bundled in direnv setup, here is a sample `.dir-locals.el` that can
be put in the root directory of the project:
```el
((haskell-mode . ((haskell-completion-backend . lsp)
(lsp-haskell-server-path . "/home/haskeller/code/wire-server/hack/bin/nix-hls.sh")
)))
```

### Ormolu integration

There are make targets `format`, `formatf`, `formatc` to re-format
Expand Down
10 changes: 10 additions & 0 deletions hack/bin/nix-hls.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

set -euo pipefail

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
TOP_LEVEL="$(cd "$DIR/../.." && pwd)"

env=$(nix-build --no-out-link "$PWD/direnv.nix")
export PATH="$env/bin:$PATH"
haskell-language-server-wrapper "$@"