-
Notifications
You must be signed in to change notification settings - Fork 10
/
.envrc
32 lines (26 loc) · 977 Bytes
/
.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
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
# postges related
export PGUSER="postgres"
export PGPASSWORD="postgres"
export PGDATABASE="medirepo_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"
use flake
if [[ ! -d "$PGDATA" ]]; then
# initital set up of database server
initdb --auth=trust --no-locale --encoding=UTF8 -U=$PGUSER >/dev/null
# point to correct unix sockets
echo "unix_socket_directories = '$PGHOST'" >> "$PGDATA/postgresql.conf"
# creates loacl database user
echo "CREATE USER $PGUSER SUPERUSER;" | postgres --single -E postgres
# creates local databse
echo "CREATE DATABASE $PGDATABASE;" | postgres --single -E postgres
fi