summaryrefslogtreecommitdiff
path: root/pkgs/servers/sql/postgresql/pg_config.nix
blob: c4cc1cee06cd07c40e9895ac3e3811a7fd6f2d2c (plain)
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
{
  diffutils,
  lib,
  replaceVarsWith,
  runtimeShell,
  stdenv,
  # PostgreSQL package
  finalPackage,
  # PostgreSQL package's outputs
  outputs,
}:

replaceVarsWith {
  name = "pg_config";
  src = ./pg_config.sh;
  dir = "bin";
  isExecutable = true;
  replacements = {
    inherit runtimeShell;
    "pg_config.env" = replaceVarsWith {
      name = "pg_config.env";
      src = "${lib.getDev finalPackage}/nix-support/pg_config.env";
      replacements = outputs;
    };
  };
  nativeCheckInputs = [
    diffutils
  ];
  # The expected output only matches when outputs have *not* been altered by postgresql.withPackages.
  postCheck = lib.optionalString (outputs.out == lib.getOutput "out" finalPackage) ''
    if [ -e ${lib.getDev finalPackage}/nix-support/pg_config.expected ]; then
        diff ${lib.getDev finalPackage}/nix-support/pg_config.expected <($out/bin/pg_config)
    fi
  '';
}