1 { lib, stdenv, perlPackages, fetchFromGitHub, fetchpatch, shortenPerlShebang }:
3 perlPackages.buildPerlPackage rec {
7 src = fetchFromGitHub {
11 hash = "sha256-4KtrsckO9Q9H0yIM0877YvWaDW02CQVAQiOKD919e9w=";
16 makeMakerFlags = [ "INSTALLDIRS=vendor" ];
18 # Avoid creating perllocal.pod, which contains a timestamp
19 installTargets = [ "pure_install" ];
22 # Fix an uninitialized variable error. Remove with the next release.
24 url = "https://github.com/darold/pgFormatter/commit/c2622c47d48cee47effecbf58a588c3cd3a7bf1a.patch";
25 sha256 = "sha256-WnQIOvfuzL2HrwtL0HaaYObrBxhXDu82jxGcqggQVhc=";
29 # Makefile.PL only accepts DESTDIR and INSTALLDIRS, but we need to set more to make this work for NixOS.
31 substituteInPlace pg_format \
32 --replace "#!/usr/bin/env perl" "#!/usr/bin/perl"
33 substituteInPlace Makefile.PL \
34 --replace "'DESTDIR' => \$DESTDIR," "'DESTDIR' => '$out/'," \
35 --replace "'INSTALLDIRS' => \$INSTALLDIRS," "'INSTALLDIRS' => \$INSTALLDIRS, 'INSTALLVENDORLIB' => 'bin/lib', 'INSTALLVENDORBIN' => 'bin', 'INSTALLVENDORSCRIPT' => 'bin', 'INSTALLVENDORMAN1DIR' => 'share/man/man1', 'INSTALLVENDORMAN3DIR' => 'share/man/man3',"
38 nativeBuildInputs = lib.optional stdenv.isDarwin shortenPerlShebang;
39 postInstall = lib.optionalString stdenv.isDarwin ''
40 shortenPerlShebang $out/bin/pg_format
46 description = "A PostgreSQL SQL syntax beautifier that can work as a console program or as a CGI";
47 homepage = "https://github.com/darold/pgFormatter";
48 changelog = "https://github.com/darold/pgFormatter/releases/tag/v${version}";
49 maintainers = [ maintainers.marsam ];
50 license = [ licenses.postgresql licenses.artistic2 ];
51 mainProgram = "pg_format";