-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathshell.nix
More file actions
53 lines (48 loc) · 1.85 KB
/
Copy pathshell.nix
File metadata and controls
53 lines (48 loc) · 1.85 KB
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
# Switch betweein `-threaded` and `+threaded` to change both the dev shell
# and the output of `nix-build` commands to build executables like hpgsql-tests
# and hpgsql-benchmarks with the single or multi-threaded GHC RTS
let threading = "+threaded";
ghc = "ghc9103";
in
{ pkgs ? import ./nix/nixpkgs.nix { inherit threading; } }:
let
postgres = pkgs.postgresql_16.withPackages (ps: with ps; [ /* pg_cron */ ]);
haskellPackages = builtins.getAttr ghc pkgs.haskell.packages;
in
haskellPackages.shellFor {
packages = p: with p; [ hpgsql hpgsql-tests hpgsql-benchmarks hpgsql-simple-compat hpgsql-simple-compat-tests ];
withHoogle = true;
buildInputs = with pkgs; [
concurrently
haskellPackages.cabal-install
haskellPackages.ghcid
haskellPackages.haskell-language-server
haskellPackages.hlint
haskellPackages.hspec-discover
heaptrack
postgres
run
];
shellHook = ''
source scripts/source-env.sh .env
# Postgres 15 insists in appearing in PATH before postgres 16.
# So we add postgres 16 _again_ to the beginning of the PATH, and also some useful scripts
export PATH="${postgres}/bin:$PATH:scripts/path"
# I tried to daemonize starting postgres but was not able
# to make it work, so we only init the cluster.
# See https://github.com/direnv/direnv/issues/755
./scripts/init-pg-cluster.sh ./conf/dev-db
export HPGSQL_THREADED="${threading}"
cat << LOCAL > cabal.project.local
tests: False
package hpgsql-tests
flags: ${threading}
package hpgsql-benchmarks
flags: ${threading}
package hpgsql-simple-compat-tests
flags: ${threading}
LOCAL
echo You should be able to start postgres with 'pg_ctl start' and use 'psql' to connect to it, and it will be independent from any your own system might have provided.
echo If 'psql' fails to connect, check logs at $PGDATA/log/
'';
}