Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ lib, stdenv, perlPackages, fetchFromGitHub, fetchpatch, shortenPerlShebang }: 2 3perlPackages.buildPerlPackage rec { 4 pname = "pgformatter"; 5 version = "5.5"; 6 7 src = fetchFromGitHub { 8 owner = "darold"; 9 repo = "pgFormatter"; 10 rev = "v${version}"; 11 hash = "sha256-4KtrsckO9Q9H0yIM0877YvWaDW02CQVAQiOKD919e9w="; 12 }; 13 14 outputs = [ "out" ]; 15 16 makeMakerFlags = [ "INSTALLDIRS=vendor" ]; 17 18 # Avoid creating perllocal.pod, which contains a timestamp 19 installTargets = [ "pure_install" ]; 20 21 patches = [ 22 # Fix an uninitialized variable error. Remove with the next release. 23 (fetchpatch { 24 url = "https://github.com/darold/pgFormatter/commit/c2622c47d48cee47effecbf58a588c3cd3a7bf1a.patch"; 25 sha256 = "sha256-WnQIOvfuzL2HrwtL0HaaYObrBxhXDu82jxGcqggQVhc="; 26 }) 27 ]; 28 29 # Makefile.PL only accepts DESTDIR and INSTALLDIRS, but we need to set more to make this work for NixOS. 30 patchPhase = '' 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'," 36 ''; 37 38 nativeBuildInputs = lib.optional stdenv.isDarwin shortenPerlShebang; 39 postInstall = lib.optionalString stdenv.isDarwin '' 40 shortenPerlShebang $out/bin/pg_format 41 ''; 42 43 doCheck = false; 44 45 meta = with lib; { 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"; 52 }; 53}