2023-03-01 04:20:00 +00:00
|
|
|
{ lib, stdenv, perlPackages, fetchFromGitHub, fetchpatch, shortenPerlShebang }:
|
2019-09-01 21:20:00 +00:00
|
|
|
|
|
|
|
perlPackages.buildPerlPackage rec {
|
|
|
|
pname = "pgformatter";
|
2023-02-03 04:20:00 +00:00
|
|
|
version = "5.5";
|
2019-09-01 21:20:00 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "darold";
|
|
|
|
repo = "pgFormatter";
|
|
|
|
rev = "v${version}";
|
2023-02-03 04:20:00 +00:00
|
|
|
hash = "sha256-4KtrsckO9Q9H0yIM0877YvWaDW02CQVAQiOKD919e9w=";
|
2019-09-01 21:20:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
outputs = [ "out" ];
|
|
|
|
|
|
|
|
makeMakerFlags = [ "INSTALLDIRS=vendor" ];
|
|
|
|
|
2021-10-16 06:00:25 +00:00
|
|
|
# Avoid creating perllocal.pod, which contains a timestamp
|
|
|
|
installTargets = [ "pure_install" ];
|
|
|
|
|
2023-03-01 04:20:00 +00:00
|
|
|
patches = [
|
|
|
|
# Fix an uninitialized variable error. Remove with the next release.
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://github.com/darold/pgFormatter/commit/c2622c47d48cee47effecbf58a588c3cd3a7bf1a.patch";
|
|
|
|
sha256 = "sha256-WnQIOvfuzL2HrwtL0HaaYObrBxhXDu82jxGcqggQVhc=";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
2019-09-01 21:20:00 +00:00
|
|
|
# Makefile.PL only accepts DESTDIR and INSTALLDIRS, but we need to set more to make this work for NixOS.
|
|
|
|
patchPhase = ''
|
|
|
|
substituteInPlace pg_format \
|
|
|
|
--replace "#!/usr/bin/env perl" "#!/usr/bin/perl"
|
|
|
|
substituteInPlace Makefile.PL \
|
|
|
|
--replace "'DESTDIR' => \$DESTDIR," "'DESTDIR' => '$out/'," \
|
|
|
|
--replace "'INSTALLDIRS' => \$INSTALLDIRS," "'INSTALLDIRS' => \$INSTALLDIRS, 'INSTALLVENDORLIB' => 'bin/lib', 'INSTALLVENDORBIN' => 'bin', 'INSTALLVENDORSCRIPT' => 'bin', 'INSTALLVENDORMAN1DIR' => 'share/man/man1', 'INSTALLVENDORMAN3DIR' => 'share/man/man3',"
|
|
|
|
'';
|
|
|
|
|
2021-01-23 12:26:19 +00:00
|
|
|
nativeBuildInputs = lib.optional stdenv.isDarwin shortenPerlShebang;
|
|
|
|
postInstall = lib.optionalString stdenv.isDarwin ''
|
2019-09-01 21:20:00 +00:00
|
|
|
shortenPerlShebang $out/bin/pg_format
|
|
|
|
'';
|
|
|
|
|
|
|
|
doCheck = false;
|
|
|
|
|
2021-01-11 07:54:33 +00:00
|
|
|
meta = with lib; {
|
2019-09-01 21:20:00 +00:00
|
|
|
description = "A PostgreSQL SQL syntax beautifier that can work as a console program or as a CGI";
|
|
|
|
homepage = "https://github.com/darold/pgFormatter";
|
2020-01-26 10:00:00 +00:00
|
|
|
changelog = "https://github.com/darold/pgFormatter/releases/tag/v${version}";
|
2019-09-01 21:20:00 +00:00
|
|
|
maintainers = [ maintainers.marsam ];
|
|
|
|
license = [ licenses.postgresql licenses.artistic2 ];
|
2023-02-03 04:20:00 +00:00
|
|
|
mainProgram = "pg_format";
|
2019-09-01 21:20:00 +00:00
|
|
|
};
|
|
|
|
}
|