Repository navigation
Expand file tree
/
Copy path.envrc
More file actions
122 lines (101 loc) · 4.29 KB
/
Copy path.envrc
File metadata and controls
122 lines (101 loc) · 4.29 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# Build a folder ./.env that contains the dev-shell which load all the right env
# vars.
#
# To speed up the nix evaluation, we only rebuild our environment when `./nix`
# or any of the `default.nix` files change. We do this by adding all these files
# to the nix store and using the store paths as a cache key.
# FUTUREWORK: The speedhack saves only a couple of Seconds when cd'ing into the
# repo's directory. The price is some state we have to manage manually (e.g.
# `rm .direnv`) and a non-intuitive usage of flakes.
#
# The hack could be replaced by the line
# `use flake .\#`
#
# The env variable exports could then be added to the flake's devShell.
nix_files=$(find . -name '*.nix' | grep -v '^./dist-newstyle')
for nix_file in $nix_files; do
watch_file "$nix_file"
done
watch_file ./services/nginz/third_party/nginx-zauth-module/*
watch_file ./libs/libzauth/**/*
store_paths=$(echo "$nix_files" ./services/nginz/third_party/nginx-zauth-module/ ./libs/libzauth/ | xargs nix-store --add ./nix)
layout_dir=$(direnv_layout_dir)
env_dir=./.env
export NIX_CONFIG='extra-experimental-features = nix-command flakes'
[[ -d "$layout_dir" ]] || mkdir -p "$layout_dir"
if [[ ! -d "$env_dir" || ! -f "$layout_dir/nix-rebuild" || "$store_paths" != $(<"$layout_dir/nix-rebuild") ]]; then
bcmd=nix
if command -v nom &>/dev/null; then
if [[ "${USE_NOM}" != "0" ]]; then
bcmd=nom
fi
fi
echo "🔧 Building environment"
$bcmd build '.#wireServer.devEnv' -Lv --out-link ./.env --fallback || return 1
echo "$store_paths" >"$layout_dir/nix-rebuild"
fi
# macOS only: nginx's compiled-in zauth module references a relative dylib
# path that only exists inside the Nix build sandbox. Resolve the real file
# in the store by its baked-in filename, but only when ./.env was actually
# rebuilt (otool/find on every shell reload would be wasteful).
if [[ "$(uname -s)" == "Darwin" ]]; then
zauth_cache="$layout_dir/dyld-library-path"
if [[ ! -f "$zauth_cache" || "$env_dir/bin/nginx" -nt "$zauth_cache" ]]; then
zauth_dir=""
if [[ -x "$env_dir/bin/nginx" ]]; then
zauth_name=$(otool -L "$env_dir/bin/nginx" 2>/dev/null | awk '/libzauth-/{print $1}' | xargs -I{} basename {})
if [[ -n "$zauth_name" ]]; then
zauth_lib=$(find /nix/store -maxdepth 3 -iname "$zauth_name" 2>/dev/null | head -n1)
[[ -n "$zauth_lib" ]] && zauth_dir=$(dirname "$zauth_lib")
fi
fi
echo "$zauth_dir" >"$zauth_cache"
fi
zauth_dir=$(<"$zauth_cache")
[[ -n "$zauth_dir" ]] && path_add DYLD_LIBRARY_PATH "$zauth_dir"
fi
PATH_add "./.env/bin"
PATH_add "./.env-hs-run/bin"
path_add "PKG_CONFIG_PATH" "./.env/lib/pkgconfig"
path_add "LIBRARY_PATH" "./.env/lib"
path_add "PYTHONPATH" "./hack/python"
PATH_add "./dist"
# source .profile from `$env`. This sets NIX_PATH to pkgs defined in
# ./nix/default.nix. Tis is useful for nix tooling that runs inside this direnv,
# e.g. "nix-shell -p foo" will get "foo" for pkgs defined in ./nix/default.nix
[[ -f "./.env/.profile" ]] && source_env "./.env/.profile"
# Locale
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
# RabbitMQ
export RABBITMQ_USERNAME=guest
export RABBITMQ_PASSWORD=alpaca-grapefruit
export RABBITMQ_USERNAME_V0=guest
export RABBITMQ_PASSWORD_V0=alpaca-grapefruit
export RABBITMQ_USERNAME_V1=guest
export RABBITMQ_PASSWORD_V1=alpaca-grapefruit
export RABBITMQ_USERNAME_V2=guest
export RABBITMQ_PASSWORD_V2=alpaca-grapefruit
export RABBITMQ_USERNAME_V3=guest
export RABBITMQ_PASSWORD_V3=alpaca-grapefruit
# Redis
export REDIS_PASSWORD=very-secure-redis-cluster-password
export REDIS_ADDITIONAL_WRITE_PASSWORD=very-secure-redis-master-password
# Integration tests
export INTEGRATION_DYNAMIC_BACKENDS_POOLSIZE=3
# AWS credentials for locally running services
# Keep these in sync with deploy/dockerephmeral/init.sh
export AWS_REGION="eu-west-1"
export AWS_ACCESS_KEY_ID="GKdeadbeefcafebabe0000000000000000"
export AWS_SECRET_ACCESS_KEY="deadbeefcafebabe0000000000000000deadbeefcafebabe0000000000000000"
# integration test suite timeout
export TEST_TIMEOUT_SECONDS=2
# OTEL
OTEL_SEMCONV_STABILITY_OPT_IN=http
# uncomment if you plan to run the integration setup manually against kube-ci
# unset AWS_REGION
# unset AWS_ACCESS_KEY_ID
# unset AWS_SECRET_ACCESS_KEY
# source_env ../cailleach/.envrc
# allow local .envrc overrides
[[ -f .envrc.local ]] && source_env .envrc.local