-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.envrc
32 lines (26 loc) · 1.15 KB
/
.envrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env bash
PATH_add bin/
# Reload if any of these files change
watch_file nix/*
watch_file .envrc.local
# Build a folder that contains all the tools
# To speed up the nix evaluation, we only rebuild our environment when `./nix`
# changes. We do this by adding its contents to the nix store and using its
# store path as a cache key. We only use this to build the dev environment. This
# will fail building in case anything inside the devshell is reaching outside
# the nix/ subfolder (such as nixos-configs, and kdb-containers)…
store_path=$(nix-store --add ./nix/)
layout_dir=$(direnv_layout_dir)
[[ -d "$layout_dir" ]] || mkdir -p "$layout_dir"
if [[ ! -d ./env || ! -f "$layout_dir/nix-rebuild" || "$store_path" != $(< "$layout_dir/nix-rebuild" ) ]]; then
nix-build "$store_path" -A env --out-link ./env
echo "$store_path" > "$layout_dir/nix-rebuild"
fi
# Load the devshell
source ./env/env.bash
# used by docker-compose to run processes with the same user ID mapping
HOST_UID=$(id -u)
HOST_GID=$(id -g)
export HOST_UID HOST_GID
# allow local .envrc overrides, used for secrets (see .envrc.local-template)
[[ -f .envrc.local ]] && source_env .envrc.local