Skip to content

Commit 20086c1

Browse files
authored
feat(devenv): use direnv to invoke nix-shell (#3745)
1 parent c4a9be9 commit 20086c1

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

.envrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
use nix

docs/CONTRIBUTING.md

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,35 @@
22

33
## Requirements
44

5-
You'll need the following tools:
5+
We recommend using the [Nix](https://nix.dev/) package manager as it makes any pain related to maintaining dependency versions [just disappear](https://twitter.com/mitchellh/status/1491102567296040961). Once nix [has been installed](https://nixos.org/download.html) the development environment can be _manually instantiated_ through the `nix-shell` command:
6+
7+
```
8+
$ cd ~/code/coder
9+
10+
# https://nix.dev/tutorials/declarative-and-reproducible-developer-environments
11+
$ nix-shell
12+
13+
...
14+
copying path '/nix/store/3ms6cs5210n8vfb5a7jkdvzrzdagqzbp-iana-etc-20210225' from 'https://cache.nixos.org'...
15+
copying path '/nix/store/dxg5aijpyy36clz05wjsyk90gqcdzbam-iana-etc-20220520' from 'https://cache.nixos.org'...
16+
copying path '/nix/store/v2gvj8whv241nj4lzha3flq8pnllcmvv-ignore-5.2.0.tgz' from 'https://cache.nixos.org'...
17+
...
18+
```
19+
20+
If [direnv](https://direnv.net/) is installed and the [hooks are configured](https://direnv.net/docs/hook.html) then the development environment can be _automatically instantiated_ thus removing the need to run `nix-shell` by hand!
21+
22+
```
23+
$ cd ~/code/coder
24+
25+
# https://direnv.net/docs/hook.html
26+
direnv: loading ~/code/coder/.envrc
27+
direnv: using nix
28+
direnv: export +AR +AS +CC +CONFIG_SHELL +CXX +HOST_PATH +IN_NIX_SHELL +LD +NIX_BINTOOLS +NIX_BINTOOLS_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu +NIX_BUILD_CORES +NIX_BUILD_TOP +NIX_CC +NIX_CC_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu +NIX_CFLAGS_COMPILE +NIX_ENFORCE_NO_NATIVE +NIX_HARDENING_ENABLE +NIX_INDENT_MAKE +NIX_LDFLAGS +NIX_STORE +NM +NODE_PATH +OBJCOPY +OBJDUMP +RANLIB +READELF +SIZE +SOURCE_DATE_EPOCH +STRINGS +STRIP +TEMP +TEMPDIR +TMP +TMPDIR +XDG_DATA_DIRS +buildInputs +buildPhase +builder +cmakeFlags +configureFlags +depsBuildBuild +depsBuildBuildPropagated +depsBuildTarget +depsBuildTargetPropagated +depsHostHost +depsHostHostPropagated +depsTargetTarget +depsTargetTargetPropagated +doCheck +doInstallCheck +mesonFlags +name +nativeBuildInputs +out +outputs +patches +phases +propagatedBuildInputs +propagatedNativeBuildInputs +shell +shellHook +stdenv +strictDeps +system ~PATH
29+
30+
🎉
31+
```
32+
33+
Alternatively if you do not want to use nix then you'll need to install the need the following tools by hand:
634
- Go 1.18+
735
- Node 14+
836
- GNU Make
@@ -12,8 +40,6 @@ You'll need the following tools:
1240
- on macOS, run `brew install libpq zstd`
1341
- on Linux, install [`zstd`](https://github.com/horta/zstd.install)
1442

15-
> **Note**:
16-
> Use [Nix](https://nix.dev/) for a one-command setup: `nix-shell`
1743

1844
### Development workflow
1945

0 commit comments

Comments
 (0)