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.
This commit is contained in:
Wolfgang Walther
2025-03-22 19:37:03 +00:00
parent 57d11c7914
commit 2b91df8004
3 changed files with 33 additions and 39 deletions
+12 -17
View File
@@ -55,8 +55,13 @@ let
]; ];
# Dynamic derivation for PostgREST # Dynamic derivation for PostgREST
postgrest = postgrest = pkgs.lib.pipe (pkgs.haskell.packages."${compiler}".callCabal2nix name src { }) [
pkgs.haskell.packages."${compiler}".callCabal2nix name src { }; # To allow ghc-datasize to be used.
lib.disableLibraryProfiling
# We are never going to use dynamic haskell libraries anyway. "Dynamic" refers to how
# non-haskell deps are linked. All haskell dependencies are always statically linked.
lib.disableSharedLibraries
];
staticHaskellPackage = import nix/static.nix { inherit compiler name pkgs src; }; staticHaskellPackage = import nix/static.nix { inherit compiler name pkgs src; };
@@ -64,15 +69,6 @@ let
devCabalOptions = devCabalOptions =
"-f dev --test-show-detail=direct"; "-f dev --test-show-detail=direct";
profiledHaskellPackages =
pkgs.haskell.packages."${compiler}".extend (_: super:
{
mkDerivation =
args:
super.mkDerivation (args // { enableLibraryProfiling = true; });
}
);
inherit (pkgs.haskell) lib; inherit (pkgs.haskell) lib;
in in
rec { rec {
@@ -85,12 +81,11 @@ rec {
lib.dontCheck postgrest; lib.dontCheck postgrest;
# Profiled dynamic executable. # Profiled dynamic executable.
postgrestProfiled = postgrestProfiled = pkgs.lib.pipe postgrestPackage [
lib.enableExecutableProfiling ( lib.enableExecutableProfiling
lib.dontHaddock ( lib.enableLibraryProfiling
lib.dontCheck (profiledHaskellPackages.callCabal2nix name src { }) lib.dontHaddock
) ];
);
inherit (postgrest) env; inherit (postgrest) env;
+19 -19
View File
@@ -72,17 +72,17 @@ The PostgREST utilities available in `nix-shell` all have names that begin with
```bash ```bash
# Note: The utilities listed here might not be up to date. # Note: The utilities listed here might not be up to date.
[nix-shell]$ postgrest-<tab> [nix-shell]$ postgrest-<tab>
postgrest-build postgrest-parallel-curl postgrest-build postgrest-profiled-run
postgrest-check postgrest-profiled-run postgrest-check postgrest-push-cachix
postgrest-clean postgrest-push-cachix postgrest-clean postgrest-release
postgrest-coverage postgrest-release postgrest-coverage postgrest-repl
postgrest-coverage-draft-overlay postgrest-repl postgrest-coverage-draft-overlay postgrest-run
postgrest-docs-build postgrest-run postgrest-docs-build postgrest-style
postgrest-docs-check postgrest-style postgrest-docs-check postgrest-style-check
postgrest-docs-dictcheck postgrest-style-check postgrest-docs-dictcheck postgrest-test-big-schema
postgrest-docs-linkcheck postgrest-test-big-schema postgrest-docs-linkcheck postgrest-test-doctests
postgrest-docs-render postgrest-test-doctests postgrest-docs-render postgrest-test-io
postgrest-docs-serve postgrest-test-io postgrest-docs-serve postgrest-test-memory
postgrest-docs-spellcheck postgrest-test-replica postgrest-docs-spellcheck postgrest-test-replica
postgrest-dump-minimal-imports postgrest-test-spec postgrest-dump-minimal-imports postgrest-test-spec
postgrest-dump-schema postgrest-test-spec-idempotence postgrest-dump-schema postgrest-test-spec-idempotence
@@ -98,27 +98,27 @@ postgrest-loadtest postgrest-with-postgresql-16
postgrest-loadtest-against postgrest-with-postgresql-17 postgrest-loadtest-against postgrest-with-postgresql-17
postgrest-loadtest-report postgrest-with-slow-pg postgrest-loadtest-report postgrest-with-slow-pg
postgrest-nixpkgs-upgrade postgrest-with-slow-postgrest postgrest-nixpkgs-upgrade postgrest-with-slow-postgrest
postgrest-parallel-curl
... ...
[nix-shell]$ [nix-shell]$
``` ```
Some additional modules like `memory` and `docker` The `docker` module has large dependencies to be build before the shell becomes
have large dependencies that would need to be built before the shell becomes
available, which could take an especially long time if the cachix binary cache available, which could take an especially long time if the cachix binary cache
is not used. You can activate those by passing a flag to `nix-shell` with is not used. You can activate it by passing a flag to `nix-shell` with
`nix-shell --arg <module> true`. This will make the respective utilities available: `nix-shell --arg docker true`. This will make the respective utilities available:
```bash ```bash
$ nix-shell --arg memory true $ nix-shell --arg docker true
[nix-shell]$ postgrest-test-m<tab> [nix-shell]$ postgrest-docker-<tab>
postgrest-test-memory postgrest-docker-load
... ...
``` ```
Note that `postgrest-test-memory` is now also available. Note that `postgrest-docker-load` is now also available.
To run one-off commands, you can also use `nix-shell --run <command>`, which To run one-off commands, you can also use `nix-shell --run <command>`, which
will launch the Nix shell, run that one command and exit. Note that the tab will launch the Nix shell, run that one command and exit. Note that the tab
+2 -3
View File
@@ -7,7 +7,6 @@
# We highly recommend that use the PostgREST binary cache by installing cachix # We highly recommend that use the PostgREST binary cache by installing cachix
# (https://app.cachix.org/) and running `cachix use postgrest`. # (https://app.cachix.org/) and running `cachix use postgrest`.
{ docker ? false { docker ? false
, memory ? false
}: }:
let let
postgrest = postgrest =
@@ -23,14 +22,14 @@ let
postgrest.devTools postgrest.devTools
postgrest.docs postgrest.docs
postgrest.loadtest postgrest.loadtest
postgrest.memory
postgrest.nixpkgsTools postgrest.nixpkgsTools
postgrest.release postgrest.release
postgrest.style postgrest.style
postgrest.tests postgrest.tests
postgrest.withTools postgrest.withTools
] ]
++ lib.optional docker postgrest.docker ++ lib.optional docker postgrest.docker;
++ lib.optional memory postgrest.memory;
in in
lib.overrideDerivation postgrest.env ( lib.overrideDerivation postgrest.env (