forked from iburzynski/jambhala
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.envrc
89 lines (70 loc) · 2.57 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
######## JAMBHALA ENVIRONMENT CONFIGURATION ########
# Do not modify the contents of this file!
# To modify your configuration, change values of variables in the .env file.
# The .env file is created automatically for you when you load the environment the first time.
# Type ENTER/RETURN in your terminal session after modifying .env to apply your changes.
#### GENERAL SETUP ####
export PROJECT_ROOT=$(git rev-parse --show-toplevel)
# Add utility scripts to PATH
PATH_add ./scripts/
# Fix project if cloned without --recurse-submodules flag
fix-submodules.sh
# Add setup scripts to PATH
PATH_add ./jsetup-utils
# Make .env file from template if absent
mk-env.sh
# Source and watch the .env file:
dotenv
watch_file .env
#### LOAD NIX ENVIRONMENT ####
# Use nix-direnv for caching/persistence:
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
# Allow unfree packages (for closed-source VS Code extensions):
export NIXPKGS_ALLOW_UNFREE=1
# Disable Boehm garbage collection on Macs to prevent seg-fault
if [[ "$(uname)" == "Darwin" ]]; then
export GC_DONT_GC=1
fi
# Load the Nix environment from flake.nix:
if use flake . --impure --accept-flake-config --no-warn-dirty; then
export JAMB_ENV_LOADED=true
# Source cardano-cli-guru environment if not already loaded (makes Guru commands available from project root)
if [[ $GURU_ENV_LOADED != true ]]; then
source_env "$PROJECT_ROOT/cardano-cli-guru"
fi
# Build cabal project locally
export CABAL_DIR="$PROJECT_ROOT/.cabal"
# Create symlink to Nix HLS binary (prevents conflict with GHCup binaries)
just link-hls
#### JAMBHALUCID SETUP ####
# Create .env.local file for Jambhalucid and populate with existing variables
env_local="$PROJECT_ROOT/jambhalucid/.env.local"
if [ -e "$env_local" ]; then
rm "$env_local"
fi
if [ "$CARDANO_NODE_NETWORK_ID" == "1" ]; then
TESTNET_NAME="preprod"
else
TESTNET_NAME="preview"
fi
touch "$env_local"
cat <<EOF >> "$env_local"
TESTNET_NAME=$TESTNET_NAME
BLOCKFROST_PROJECT_ID_PREPROD=$BLOCKFROST_PROJECT_ID_PREPROD
BLOCKFROST_PROJECT_ID_PREVIEW=$BLOCKFROST_PROJECT_ID_PREVIEW
EOF
#### HASKELL DOJO SETUP ####
if [ ! -d "$PWD/haskell-dojo" ]; then
if [ -n "$GITHUB_ID" ]; then
repo_url="https://github.com/$GITHUB_ID/haskell-dojo"
if curl --output /dev/null --silent --head --fail "$repo_url"; then
git clone "$repo_url"
fi
fi
fi
else
echo "Error loading flake.nix"
exit 1
fi