nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 bison,
3 fetchFromGitHub,
4 flex,
5 lib,
6 perl,
7 postgresql,
8 postgresqlBuildExtension,
9 stdenv,
10}:
11
12let
13 hashes = {
14 # Issue tracking PostgreSQL 18 support: https://github.com/apache/age/issues/2164
15 # "18" = "";
16 "17" = "sha256-gqoAhVqQaDhe5CIcTc//1HonQLP1zoBIGuCQuXsJy+A=";
17 "16" = "sha256-iukdi2c3CukGvjuTojybFFAZBlAw8GEfzFPr2qJuwTA=";
18 "15" = "sha256-webZWgWZGnSoXwTpk816tjbtHV1UIlXkogpBDAEL4gM=";
19 "14" = "sha256-jZXhcYBubpjIJ8M5JHXKV5f6VK/2BkypH3P7nLxZz3E=";
20 "13" = "sha256-HR6nnWt/V2a0rD5eHHUsFIZ1y7lmvLz36URt9pPJnCw=";
21 };
22in
23postgresqlBuildExtension (finalAttrs: {
24 pname = "age";
25 version = if lib.versionAtLeast postgresql.version "16" then "1.6.0-rc0" else "1.5.0-rc0";
26
27 src = fetchFromGitHub {
28 owner = "apache";
29 repo = "age";
30 tag = "PG${lib.versions.major postgresql.version}/v${finalAttrs.version}";
31 hash =
32 hashes.${lib.versions.major postgresql.version}
33 or (throw "Source for Age is not available for ${postgresql.version}");
34 };
35
36 makeFlags = [
37 "BISON=${bison}/bin/bison"
38 "FLEX=${flex}/bin/flex"
39 "PERL=${perl}/bin/perl"
40 ];
41
42 enableUpdateScript = false;
43 passthru.tests = stdenv.mkDerivation {
44 inherit (finalAttrs) version src;
45
46 pname = "age-regression";
47
48 dontConfigure = true;
49
50 buildPhase =
51 let
52 postgresqlAge = postgresql.withPackages (_: [ finalAttrs.finalPackage ]);
53 in
54 ''
55 # The regression tests need to be run in the order specified in the Makefile.
56 echo -e "include Makefile\nfiles:\n\t@echo \$(REGRESS)" > Makefile.regress
57 REGRESS_TESTS=$(make -f Makefile.regress files)
58
59 ${lib.getDev postgresql}/lib/pgxs/src/test/regress/pg_regress \
60 --inputdir=./ \
61 --bindir='${postgresqlAge}/bin' \
62 --encoding=UTF-8 \
63 --load-extension=age \
64 --inputdir=./regress --outputdir=./regress --temp-instance=./regress/instance \
65 --port=61958 --dbname=contrib_regression \
66 $REGRESS_TESTS
67 '';
68
69 installPhase = ''
70 touch $out
71 '';
72 };
73
74 meta = {
75 broken = !builtins.elem (lib.versions.major postgresql.version) (builtins.attrNames hashes);
76 description = "Graph database extension for PostgreSQL";
77 homepage = "https://age.apache.org/";
78 changelog = "https://github.com/apache/age/raw/PG${lib.versions.major postgresql.version}/v${finalAttrs.version}/RELEASE";
79 maintainers = [ ];
80 platforms = postgresql.meta.platforms;
81 license = lib.licenses.asl20;
82 };
83})