forked from PrimalHQ/primal-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
shell.nix
67 lines (58 loc) · 1.42 KB
/
shell.nix
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
{ pkgs ? import <nixpkgs> { } }:
with pkgs;
mkShell {
buildInputs = [
julia
secp256k1
gcc
postgresql_15
ephemeralpg
gawk
rustup
pkg-config
icu
readline
flex
bison
zlib
clang
libclang.lib
glibc.dev
openssl
];
start_julia = ''
julia --project -t8 -L pkg.jl
'';
start_postgres = pkgs.writeShellScript "start_postgres.sh" ''
set -ex
PGVER=$(pg_ctl -V | awk '{print $NF}')
PGHOST="$(pwd)/var/pg"
if ! [ -f pgurl ]; then
mkdir -p $(pwd)/var
pg_tmp -w 0 -k -d $(pwd)/var/pg || true
echo "postgresql:///test?host=$(echo $PGHOST | sed 's:/:%2F:g')" > pgurl
fi
echo "pgurl: $(cat pgurl)"
'';
stop_postgres = pkgs.writeShellScript "stop_postgres.sh" ''
set -ex
pg_ctl -w -D $(pwd)/var/pg/1*.* stop
rm -fv pgurl
'';
connect_to_postgres = pkgs.writeShellScript "connect_to_pg.sh" ''
psql $(cat pgurl)
'';
start_primal_server = pkgs.writeShellScript "start_primal_server.sh" ''
set -ex
export PRIMALSERVER_RELAYS='few-relays.txt'
export PRIMALSERVER_PGCONNSTR="$(cat pgurl)"
export PRIMALSERVER_AUTO_FETCH_MISSING_EVENTS="1"
export LD_LIBRARY_PATH=".:$(pwd):$LD_LIBRARY_PATH"
julia --project -t8 -L pkg.jl -L load.jl -L start.jl
'';
shellHook = ''
export LD_LIBRARY_PATH=${secp256k1}/lib:$PWD:.
export NIX_LD=${glibc}/lib/ld-linux-x86-64.so.2
make
'';
}