1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
{
stdenv,
lib,
fetchurl,
docbook_xsl,
docbook_xsl_ns,
gettext,
libxml2,
libxslt,
glibcLocales,
docbook_xml_dtd_45,
docbook_sgml_dtd_41,
opensp,
bash,
perl,
buildPerlPackage,
ModuleBuild,
TextWrapI18N,
LocaleGettext,
SGMLSpm,
UnicodeLineBreak,
PodParser,
YAMLTiny,
SyntaxKeywordTry,
writeShellScriptBin,
}:
buildPerlPackage rec {
pname = "po4a";
version = "0.74";
src = fetchurl {
url = "https://github.com/mquinson/po4a/releases/download/v${version}/po4a-${version}.tar.gz";
hash = "sha256-JfwyPyuje71Iw68Ov0mVJkSw5GgmH5hjPpEhmoOP58I=";
};
patches = [
# Fix compatibility with gettext >= 1.0, whose msginit merges into
# existing files instead of overwriting, producing broken PO headers
# when the output file already exists but is empty.
# https://github.com/mquinson/po4a/issues/636
./gettext-1.0-msginit-compat.patch
];
strictDeps = true;
nativeBuildInputs =
# the tests for the tex-format use kpsewhich -- texlive's file finding utility.
# We don't want to depend on texlive here, so we replace it with a minimal
# shellscript that suffices for the tests in t/fmt/tex/, i.e. it looks up
# subtext.tex and article.cls to appropriate files, but doesn't find article-wrong.cls.
let
kpsewhich-stub = writeShellScriptBin "kpsewhich" ''
srcdir="$NIX_BUILD_TOP/${lib.strings.removeSuffix ".tar.gz" src.name}"
[[ $1 = "article.cls" ]] && echo /dev/null
[[ $1 = "subtext.tex" ]] && echo "$srcdir/t/fmt/tex/subtext.tex"
'';
in
[
gettext
libxml2
libxslt
docbook_xsl
docbook_xsl_ns
ModuleBuild
docbook_xml_dtd_45
docbook_sgml_dtd_41
opensp
kpsewhich-stub
glibcLocales
];
# TODO: TermReadKey was temporarily removed from propagatedBuildInputs to unfreeze the build
propagatedBuildInputs =
lib.optionals (!stdenv.hostPlatform.isMusl) [
TextWrapI18N
]
++ [
LocaleGettext
SGMLSpm
UnicodeLineBreak
PodParser
YAMLTiny
SyntaxKeywordTry
];
buildInputs = [ bash ];
env = {
LC_ALL = "en_US.UTF-8";
SGML_CATALOG_FILES = "${docbook_xml_dtd_45}/xml/dtd/docbook/catalog.xml";
};
preConfigure = ''
touch Makefile.PL
export PERL_MB_OPT="--install_base=$out --prefix=$out"
'';
buildPhase = ''
perl Build.PL --install_base=$out --install_path="lib=$out/${perl.libPrefix}"
./Build build
'';
# Disabling tests on musl
# Void linux package have investigated the failure and tracked it down to differences in gettext behavior. They decided to disable tests.
# https://github.com/void-linux/void-packages/pull/34029#issuecomment-973267880
# Alpine packagers have not worried about running the tests until now:
# https://git.alpinelinux.org/aports/tree/main/po4a/APKBUILD#n11
#
# Disabling tests on Darwin until https://github.com/NixOS/nixpkgs/issues/236560 is resolved.
doCheck = (!stdenv.hostPlatform.isMusl) && (!stdenv.hostPlatform.isDarwin);
checkPhase = ''
export SGML_CATALOG_FILES=${docbook_sgml_dtd_41}/sgml/dtd/docbook-4.1/docbook.cat
./Build test
'';
installPhase = ''
./Build install
for f in $out/bin/*; do
substituteInPlace $f --replace "#! /usr/bin/env perl" "#!${perl}/bin/perl"
substituteInPlace $f --replace "exec perl" "exec ${perl}/bin/perl"
done
'';
meta = {
description = "Tools for helping translation of documentation";
homepage = "https://po4a.org";
license = with lib.licenses; [ gpl2Plus ];
};
}
|