-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy path.envrc
20 lines (19 loc) · 1.14 KB
/
.envrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# .env is a docker compose default env, but it only supports name=value pairs
nix_direnv_watch_file shell.nix
[ -f .env ] && source .env
[ -f .env ] || echo "WARNING: .env file is missing, you may need to decrypt .env.gpg"
# now we export the above values so direnv picks them up
# we do this cleverly (and hopefully in a shell-agnostic/POSIXy way) so as not to expose the dict keys
# first we strip any commented lines,
# then we select field 1 delimited by =,
# then we pass this to export one line at a time via xargs.
# xargs and export are builtins so YMMV with other shells.
# We also prepend path with the local bindir (idempotently)
export PATH=./bin:${PATH//\.\/bin:/}
export NIXPKGS_ALLOW_INSECURE=1
# take the env and convert to ENV vars
[ -f .env ] && export $(cat .env | grep -v -s -e '^\s*#' | cut -d "=" -f 1 | xargs -L 1)
# take the tool-versions and convert to proper normalized ENV vars
[ -f .tool-versions ] && export $(cat .tool-versions | grep -v -s -e '^\s*#' | tr '[:lower:]' '[:upper:]' | sed 's/-RC/-rc/g' | sed 's/-OTP-/-otp-/g' | sed 's/ /_VERSION=/g')
[ -f .tool-versions ] || echo "WARNING: .tool-versions file is missing"
use flake