2021-01-15 22:18:51 +00:00
|
|
|
{ lib, stdenv, perlPackages, fetchFromGitHub, shortenPerlShebang }:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
perlPackages.buildPerlPackage rec {
|
|
|
|
pname = "pgformatter";
|
2022-08-12 12:06:08 +00:00
|
|
|
version = "5.3";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "darold";
|
|
|
|
repo = "pgFormatter";
|
|
|
|
rev = "v${version}";
|
2022-08-12 12:06:08 +00:00
|
|
|
sha256 = "sha256-W6xIUQhCUuPo2oIArqlM8RX2hlrPts12rTQQo+/74iM=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
outputs = [ "out" ];
|
|
|
|
|
|
|
|
makeMakerFlags = [ "INSTALLDIRS=vendor" ];
|
|
|
|
|
2021-10-17 02:12:59 +00:00
|
|
|
# Avoid creating perllocal.pod, which contains a timestamp
|
|
|
|
installTargets = [ "pure_install" ];
|
|
|
|
|
2020-04-24 23:36:52 +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-02-05 17:12:51 +00:00
|
|
|
nativeBuildInputs = lib.optional stdenv.isDarwin shortenPerlShebang;
|
|
|
|
postInstall = lib.optionalString stdenv.isDarwin ''
|
2020-04-24 23:36:52 +00:00
|
|
|
shortenPerlShebang $out/bin/pg_format
|
|
|
|
'';
|
|
|
|
|
|
|
|
doCheck = false;
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +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";
|
|
|
|
changelog = "https://github.com/darold/pgFormatter/releases/tag/v${version}";
|
|
|
|
maintainers = [ maintainers.marsam ];
|
|
|
|
license = [ licenses.postgresql licenses.artistic2 ];
|
|
|
|
};
|
|
|
|
}
|