Skip to content

Commit 2b91df8

Browse files
nix: Disable building profiled or dynamic libraries by default
We never need dynamic haskell libraries, because even the dynamic builds only dynamically link non-haskell dependencies, but always link haskell dependencies statically. Profiled libraries are only required when running the memory test, so explicitly enable them for the profiled package. This also means, that we don't need to hide the memory test behind a feature flag anymore. The reason always was assumed to be the big number of rebuilds required for it. I assume ever since we moved off of static-haskell-nix and back to nixpkgs-based builds, we have been building profiled libraries for all our dependencies anway.
1 parent 57d11c7 commit 2b91df8

File tree

3 files changed

+33
-39
lines changed

3 files changed

+33
-39
lines changed

default.nix

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -55,24 +55,20 @@ let
5555
];
5656

5757
# Dynamic derivation for PostgREST
58-
postgrest =
59-
pkgs.haskell.packages."${compiler}".callCabal2nix name src { };
58+
postgrest = pkgs.lib.pipe (pkgs.haskell.packages."${compiler}".callCabal2nix name src { }) [
59+
# To allow ghc-datasize to be used.
60+
lib.disableLibraryProfiling
61+
# We are never going to use dynamic haskell libraries anyway. "Dynamic" refers to how
62+
# non-haskell deps are linked. All haskell dependencies are always statically linked.
63+
lib.disableSharedLibraries
64+
];
6065

6166
staticHaskellPackage = import nix/static.nix { inherit compiler name pkgs src; };
6267

6368
# Options passed to cabal in dev tools and tests
6469
devCabalOptions =
6570
"-f dev --test-show-detail=direct";
6671

67-
profiledHaskellPackages =
68-
pkgs.haskell.packages."${compiler}".extend (_: super:
69-
{
70-
mkDerivation =
71-
args:
72-
super.mkDerivation (args // { enableLibraryProfiling = true; });
73-
}
74-
);
75-
7672
inherit (pkgs.haskell) lib;
7773
in
7874
rec {
@@ -85,12 +81,11 @@ rec {
8581
lib.dontCheck postgrest;
8682

8783
# Profiled dynamic executable.
88-
postgrestProfiled =
89-
lib.enableExecutableProfiling (
90-
lib.dontHaddock (
91-
lib.dontCheck (profiledHaskellPackages.callCabal2nix name src { })
92-
)
93-
);
84+
postgrestProfiled = pkgs.lib.pipe postgrestPackage [
85+
lib.enableExecutableProfiling
86+
lib.enableLibraryProfiling
87+
lib.dontHaddock
88+
];
9489

9590
inherit (postgrest) env;
9691

nix/README.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -72,17 +72,17 @@ The PostgREST utilities available in `nix-shell` all have names that begin with
7272
```bash
7373
# Note: The utilities listed here might not be up to date.
7474
[nix-shell]$ postgrest-<tab>
75-
postgrest-build postgrest-parallel-curl
76-
postgrest-check postgrest-profiled-run
77-
postgrest-clean postgrest-push-cachix
78-
postgrest-coverage postgrest-release
79-
postgrest-coverage-draft-overlay postgrest-repl
80-
postgrest-docs-build postgrest-run
81-
postgrest-docs-check postgrest-style
82-
postgrest-docs-dictcheck postgrest-style-check
83-
postgrest-docs-linkcheck postgrest-test-big-schema
84-
postgrest-docs-render postgrest-test-doctests
85-
postgrest-docs-serve postgrest-test-io
75+
postgrest-build postgrest-profiled-run
76+
postgrest-check postgrest-push-cachix
77+
postgrest-clean postgrest-release
78+
postgrest-coverage postgrest-repl
79+
postgrest-coverage-draft-overlay postgrest-run
80+
postgrest-docs-build postgrest-style
81+
postgrest-docs-check postgrest-style-check
82+
postgrest-docs-dictcheck postgrest-test-big-schema
83+
postgrest-docs-linkcheck postgrest-test-doctests
84+
postgrest-docs-render postgrest-test-io
85+
postgrest-docs-serve postgrest-test-memory
8686
postgrest-docs-spellcheck postgrest-test-replica
8787
postgrest-dump-minimal-imports postgrest-test-spec
8888
postgrest-dump-schema postgrest-test-spec-idempotence
@@ -98,27 +98,27 @@ postgrest-loadtest postgrest-with-postgresql-16
9898
postgrest-loadtest-against postgrest-with-postgresql-17
9999
postgrest-loadtest-report postgrest-with-slow-pg
100100
postgrest-nixpkgs-upgrade postgrest-with-slow-postgrest
101+
postgrest-parallel-curl
101102
...
102103

103104
[nix-shell]$
104105

105106
```
106107

107-
Some additional modules like `memory` and `docker`
108-
have large dependencies that would need to be built before the shell becomes
108+
The `docker` module has large dependencies to be build before the shell becomes
109109
available, which could take an especially long time if the cachix binary cache
110-
is not used. You can activate those by passing a flag to `nix-shell` with
111-
`nix-shell --arg <module> true`. This will make the respective utilities available:
110+
is not used. You can activate it by passing a flag to `nix-shell` with
111+
`nix-shell --arg docker true`. This will make the respective utilities available:
112112

113113
```bash
114-
$ nix-shell --arg memory true
115-
[nix-shell]$ postgrest-test-m<tab>
116-
postgrest-test-memory
114+
$ nix-shell --arg docker true
115+
[nix-shell]$ postgrest-docker-<tab>
116+
postgrest-docker-load
117117
...
118118

119119
```
120120

121-
Note that `postgrest-test-memory` is now also available.
121+
Note that `postgrest-docker-load` is now also available.
122122

123123
To run one-off commands, you can also use `nix-shell --run <command>`, which
124124
will launch the Nix shell, run that one command and exit. Note that the tab

shell.nix

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
# We highly recommend that use the PostgREST binary cache by installing cachix
88
# (https://app.cachix.org/) and running `cachix use postgrest`.
99
{ docker ? false
10-
, memory ? false
1110
}:
1211
let
1312
postgrest =
@@ -23,14 +22,14 @@ let
2322
postgrest.devTools
2423
postgrest.docs
2524
postgrest.loadtest
25+
postgrest.memory
2626
postgrest.nixpkgsTools
2727
postgrest.release
2828
postgrest.style
2929
postgrest.tests
3030
postgrest.withTools
3131
]
32-
++ lib.optional docker postgrest.docker
33-
++ lib.optional memory postgrest.memory;
32+
++ lib.optional docker postgrest.docker;
3433

3534
in
3635
lib.overrideDerivation postgrest.env (

0 commit comments

Comments
 (0)