nixpkgs/pkgs/tools/misc/pgbadger/default.nix
Connor Feeley 6d50b4ba87 pgbadger: fix build on darwin
The pgbadger build was failing on darwin due to an error while trying to
generate the package's documentation.

The pgbadger script is executed during the build to dump the help text.
The script's shebang line is too long on Darwin and needs to be
shortened using 'shortenPerlShebang' for it to execute.
2023-11-20 17:19:05 -08:00

41 lines
1.2 KiB
Nix

{ buildPerlPackage, shortenPerlShebang, stdenv, lib, fetchFromGitHub, which, bzip2, PodMarkdown, JSONXS
, TextCSV_XS }:
buildPerlPackage rec {
pname = "pgbadger";
version = "12.2";
src = fetchFromGitHub {
owner = "darold";
repo = "pgbadger";
rev = "v${version}";
hash = "sha256-IzfpDqzS5VcehkPsFxyn3kJsvXs8nLgJ3WT8ZCmIDxI=";
};
postPatch = ''
patchShebangs ./pgbadger
'';
# pgbadger has too many `-Idir` flags on its shebang line on Darwin,
# causing the build to fail when trying to generate the documentation.
# Rewrite the -I flags in `use lib` form.
preBuild = lib.optionalString stdenv.isDarwin ''
shortenPerlShebang ./pgbadger
'';
outputs = [ "out" ];
PERL_MM_OPT = "INSTALL_BASE=${placeholder "out"}";
buildInputs = [ PodMarkdown JSONXS TextCSV_XS ];
nativeBuildInputs = lib.optionals stdenv.isDarwin [ shortenPerlShebang ];
nativeCheckInputs = [ which bzip2 ];
meta = {
homepage = "https://github.com/darold/pgbadger";
description = "A fast PostgreSQL Log Analyzer";
changelog = "https://github.com/darold/pgbadger/raw/v${version}/ChangeLog";
license = lib.licenses.postgresql;
maintainers = lib.teams.determinatesystems.members;
};
}