-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.envrc
49 lines (41 loc) · 1.39 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
export GPG_TTY="$(tty)"
# this allows mix to work on the local directory
export MIX_HOME=$PWD/.nix-mix
export HEX_HOME=$PWD/.nix-mix
export PATH=$MIX_HOME/bin:$HEX_HOME/bin:$PATH
export ERL_AFLAGS="-kernel shell_history enabled"
export LANG=en_US.UTF-8
use flake
# Install mix dependencies
if ! test -d deps; then
mix deps.get
fi
USE_LOCAL_POSTGRES=false
# Setup postgresql
if test -d "/Applications/Postgres.app"; then
export DATABASE_USER="$(whoami)"
export DATABASE_PASSWORD=""
elif $USE_LOCAL_POSTGRES; then
# postges related
export DATABASE_USER="peapescarte"
export DATABASE_PASSWORD="peapescarte"
export PG_DATABASE="live_poll_dev"
# keep all your db data in a folder inside the project
export PGHOST="$PWD/.postgres"
export PGDATA="$PGHOST/data"
export PGLOG="$PGHOST/server.log"
if [[ ! -d "$PGDATA" ]]; then
# initital set up of database server
initdb --auth=trust --no-locale --encoding=UTF8 -U=$DATABASE_USER >/dev/null
# point to correct unix sockets
echo "unix_socket_directories = '$PGHOST'" >> "$PGDATA/postgresql.conf"
# creates loacl database user
echo "CREATE USER $DATABASE_USER SUPERUSER;" | postgres --single -E postgres
# creates local databse
echo "CREATE DATABASE $PG_DATABASE;" | postgres --single -E postgres
fi
else
export DATABASE_USER="postgres"
export DATABASE_PASSWORD="postgres"
export PG_DATABASE="live_poll_dev"
fi