1{
2 diffutils,
3 lib,
4 replaceVarsWith,
5 runtimeShell,
6 stdenv,
7 # PostgreSQL package
8 finalPackage,
9 # PostgreSQL package's outputs
10 outputs,
11}:
12
13replaceVarsWith {
14 name = "pg_config";
15 src = ./pg_config.sh;
16 dir = "bin";
17 isExecutable = true;
18 replacements = {
19 inherit runtimeShell;
20 "pg_config.env" = replaceVarsWith {
21 name = "pg_config.env";
22 src = "${lib.getDev finalPackage}/nix-support/pg_config.env";
23 replacements = outputs;
24 };
25 };
26 nativeCheckInputs = [
27 diffutils
28 ];
29 # The expected output only matches when outputs have *not* been altered by postgresql.withPackages.
30 postCheck = lib.optionalString (outputs.out == lib.getOutput "out" finalPackage) ''
31 if [ -e ${lib.getDev finalPackage}/nix-support/pg_config.expected ]; then
32 diff ${lib.getDev finalPackage}/nix-support/pg_config.expected <($out/bin/pg_config)
33 fi
34 '';
35}