nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 perlPackages,
4 fetchFromGitHub,
5 versionCheckHook,
6}:
7
8perlPackages.buildPerlPackage rec {
9 pname = "pgformatter";
10 version = "5.9";
11
12 src = fetchFromGitHub {
13 owner = "darold";
14 repo = "pgFormatter";
15 tag = "v${version}";
16 hash = "sha256-G4Bbg8tNlwV8VCVKCamhlQ/pGf8hWCkABm6f8i5doos=";
17 };
18
19 outputs = [ "out" ];
20
21 makeMakerFlags = [ "INSTALLDIRS=vendor" ];
22
23 # Avoid creating perllocal.pod, which contains a timestamp
24 installTargets = [ "pure_install" ];
25
26 # Makefile.PL only accepts DESTDIR and INSTALLDIRS, but we need to set more to make this work for NixOS.
27 postPatch = ''
28 substituteInPlace pg_format \
29 --replace-fail "#!/usr/bin/env perl" "#!/usr/bin/perl"
30
31 substituteInPlace Makefile.PL \
32 --replace-fail \
33 "'DESTDIR' => \$DESTDIR," \
34 "'DESTDIR' => '$out/'," \
35 --replace-fail \
36 "'INSTALLDIRS' => \$INSTALLDIRS," \
37 "'INSTALLDIRS' => \$INSTALLDIRS, 'INSTALLVENDORLIB' => 'bin/lib', 'INSTALLVENDORBIN' => 'bin', 'INSTALLVENDORSCRIPT' => 'bin', 'INSTALLVENDORMAN1DIR' => 'share/man/man1', 'INSTALLVENDORMAN3DIR' => 'share/man/man3',"
38
39 patchShebangs .
40 '';
41
42 nativeInstallCheckInputs = [ versionCheckHook ];
43 versionCheckProgramArg = "--version";
44 doInstallCheck = true;
45
46 meta = {
47 description = "PostgreSQL SQL syntax beautifier that can work as a console program or as a CGI";
48 homepage = "https://github.com/darold/pgFormatter";
49 changelog = "https://github.com/darold/pgFormatter/releases/tag/${src.tag}";
50 maintainers = with lib.maintainers; [
51 thunze
52 mfairley
53 ];
54 license = [
55 lib.licenses.postgresql
56 lib.licenses.artistic2
57 ];
58 mainProgram = "pg_format";
59 };
60}