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