-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathtest.nix
More file actions
38 lines (33 loc) · 980 Bytes
/
test.nix
File metadata and controls
38 lines (33 loc) · 980 Bytes
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
{ pkgs ? import <nixpkgs> { }, ... }:
let
pgData = "./pgData";
testPkgs = ghc: [
ghc.HUnit
ghc.regex-compat
ghc.HDBC
ghc.HDBC-postgresql
];
in
pkgs.mkShell {
inputsFrom = [
(pkgs.haskell.packages.ghc90.callCabal2nix "haskelldb-2.2.4.1" ./. { }).env
(pkgs.haskell.packages.ghc90.ghcWithPackages testPkgs)
];
buildInputs = [
pkgs.cabal-install
pkgs.postgresql
];
shellHook = ''
cabal build
echo "Setting up PostgreSQL..."
export PGDATA="$(realpath ${pgData})"
echo "Initializing database cluster in local directory at $PGDATA, will run db server with current user $(whoami)"
if [ -d "$PGDATA" ]; then
rm -rf "$PGDATA"
fi
mkdir -p "$PGDATA"
initdb --auth-local=trust --auth-host=trust --pgdata "$PGDATA" -c "unix_socket_directories=$PGDATA"
pg_ctl --pgdata="$PGDATA" -l "$PGDATA/logfile" start
trap "echo 'Stopping PostgreSQL'; pg_ctl --pgdata=$PGDATA -w stop" EXIT
'';
}