-
Notifications
You must be signed in to change notification settings - Fork 0
/
.envrc
65 lines (53 loc) · 2.69 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
bash tools/check-correct-nix-install.sh
# Enable the nix-community direnv integration
if ! has nix_direnv_version || ! nix_direnv_version 3.0.4; then
source_url \
"https://raw.githubusercontent.com/nix-community/nix-direnv/3.0.4/direnvrc" "sha256-DzlYZ33mWF/Gs8DDeyjr8mnVmQGx7ASYqA5WlxwvBG4="
fi
# [tag:nix-direnv-watch-nix-files] Make sure we watch all files relevant to the
# "boostrap phase" here, so that changes appropriately cause the shell to be
# reloaded. Any extra nix files situated near the Flake should be added here.
watch_file buck/nix/buck2/Cargo.lock buck/nix/buck2/default.nix
watch_file buck/nix/toolchains/default.nix
watch_file buck/nix/flake.nix buck/nix/flake.lock
# Enable the flake
use flake . --accept-flake-config
# [tag:auto-watchman] In order to help keep track of files more accurately, we
# use Watchman, and we automatically start it if it's not already running, and
# the user has allowed it. This is a bit of a hack, but it helps keep the shell
# environment clean.
if [ "$(uname)" = "Darwin" ]; then
# FIXME: macOS support
echo "WARNING: direnv: watchman: not enabling, because we're on macOS"
elif [ ! -f .use-watchman ] && [ -z "$CI_RUNNING" ]; then
# FIXME: prompt about this file to the user
echo "WARNING: direnv: watchman: not enabled, because " \
".use-watchman is missing, and we're not in a CI build"
else
[ "$CI_RUNNING" = "true" ] &&
echo "direnv: watchman: enabling, because we're running in a CI build"
# XXX FIXME: shouldn't require systemd on Linux, but in practice
# systemd is the only option for multi-user Nix and the only thing supported by
# upstream, so it is what it is.
[ ! -d /run/systemd/system ] &&
echo "ERROR: direnv: watchman: cannot enable, because you aren't using systemd" &&
exit 1
export WATCHMAN_SOCK="$HOME/.local/state/watchman/.watchman-socket"
if ! systemctl --user is-active --quiet watchman; then
echo "direnv: watchman: no service active; starting a transient watchman.service user unit..."
systemd-run -q --user \
-u watchman.service \
--working-directory="$HOME/.local/state/watchman" \
-p StateDirectory=watchman \
-p StandardOutput=journal \
-p Restart=on-failure \
watchman --foreground \
-u "$WATCHMAN_SOCK" \
--logfile="$HOME/.local/state/watchman/log" \
--statefile="$HOME/.local/state/watchman/state" \
--pidfile="$HOME/.local/state/watchman/pid"
echo "direnv: watchman: ok, see 'systemctl --user status watchman.service' for details"
else
echo "direnv: watchman: service is already active, continuing..."
fi
fi