-
Notifications
You must be signed in to change notification settings - Fork 3
/
.envrc
33 lines (26 loc) · 959 Bytes
/
.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
33
ssh-add -K &> /dev/null || true
my_ssh_auth_sock=$SSH_AUTH_SOCK
# Usage: use nix_shell
#
# Works like use_nix, except that it's only rebuilt if the shell.nix or shell.nix file changes.
# This avoids scenarios where the nix-channel is being updated and all the projects now need to be re-built.
#
# To force the reload the derivation, run `touch shell.nix`
use_nix_shell() {
local nixcache=".direnv.cache"
local tempfile=
if [[ ! -e "$nixcache" ]] || [[ ".envrc" -nt "$nixcache" ]] || [[ "shell.nix" -nt "$nixcache" ]] || [[ "shell.nix" -nt "$nixcache" ]]; then
tempfile="$(mktemp "$nixcache.XXXXXX")"
nix-shell --show-trace --run 'direnv dump' > "$tempfile" && mv "$tempfile" "$nixcache"
rm -f "$tempfile"
tempfile=
fi
direnv_load cat "$nixcache"
for f in $(git ls-files '*.nix'); do
watch_file $f
done
}
# Configure a custom nix Cache
export NIX_CONF_DIR="$(pwd)"
use_nix_shell
export SSH_AUTH_SOCK=$my_ssh_auth_sock