forked from iburzynski/jambhala
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.envrc
85 lines (69 loc) · 2.84 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
######## 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)
# Fix project if cloned without --recurse-submodules flag:
if [ ! "$(ls -A jambhalucid)" ] || [ ! "$(ls -A cardano-ez-installer)" ] || [ ! "$(ls -A cardano-cli-guru)" ]; then
git submodule update --init --recursive
git submodule foreach 'git checkout main'
fi
# Add setup and utility scripts to PATH
PATH_add ./setup:./scripts/
#### LOAD NIX ENVIRONMENT ####
# Use nix-direnv for caching/persistence:
if ! has nix_direnv_version || ! nix_direnv_version 2.3.0; then
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.3.0/direnvrc" "sha256-Dmd+j63L84wuzgyjITIfSxSD57Tx7v51DMxVZOsiUD8="
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:
use flake . --impure --accept-flake-config
# Create symlink to HLS binary to prevent buggy VS Code/Codium behavior (conflict with GHCup binaries)
ln -s -f $(which haskell-language-server) .vscode/haskell-language-server.link
# Source Cardano Guru environment if not already loaded (makes Guru commands available from project root)
export JAMB_ENV_LOADED=true
if [[ $GURU_ENV_LOADED != true ]]; then
source_env "$PROJECT_ROOT/cardano-cli-guru"
fi
#### .ENV CONFIG ####
# Create .env file with default environment variables if absent:
if [ ! -f .env ]; then
touch .env
cat <<EOF >> .env
NODE_RELEASE="8.1.2" # Replace with newer version and re-run the script to update your installation
CARDANO_SRC_PATH="\$HOME/cardano-src" # Where cardano-node source files will be saved
CARDANO_PATH="\$HOME/cardano" # Where node database and config files will be saved
VIM_MODE=false
GITHUB_ID=""
EOF
fi
# Source and watch the .env file:
dotenv
watch_file .env
#### JAMBHALUCID SETUP ####
# Create .env.local file for Jambhalucid and populate with existing variables
env_local="$PROJECT_ROOT/jambhalucid/.env.local"
if [ ! -f "$env_local" ]; then
touch "$env_local"
cat <<EOF >> "$env_local"
TESTNET_NAME=preview
BLOCKFROST_PROJECT_ID_PREPROD=preprodProjectID
BLOCKFROST_PROJECT_ID_PREVIEW=previewProjectID
EOF
fi
#### 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