nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenvNoCC,
4 fetchurl,
5 unzip,
6 jre,
7 jre8,
8 genericUpdater,
9 writeShellScript,
10 makeWrapper,
11 common-updater-scripts,
12 gnused,
13}:
14
15let
16 inherit (lib.versions) major majorMinor splitVersion;
17 inherit (lib.strings) concatStringsSep versionAtLeast;
18
19 common =
20 {
21 pname,
22 version,
23 src,
24 description,
25 java ? jre,
26 prog ? null,
27 jar ? null,
28 license ? lib.licenses.mpl20,
29 updateScript ? null,
30 }:
31 stdenvNoCC.mkDerivation (
32 finalAttrs:
33 let
34 mainProgram = if prog == null then pname else prog;
35 jar' = if jar == null then pname else jar;
36 in
37 {
38 inherit pname version src;
39
40 nativeBuildInputs = [
41 unzip
42 makeWrapper
43 ];
44
45 sourceRoot = ".";
46
47 installPhase = ''
48 runHook preInstall
49
50 install -Dm444 -t $out/share/java/ *.jar
51 mv doc $out/share
52
53 mkdir -p $out/bin
54 makeWrapper ${lib.getExe jre} $out/bin/${mainProgram} \
55 --add-flags "-jar $out/share/java/${jar'}.jar"
56
57 # Other distributions like debian distribute it as saxon*-xslt,
58 # this makes compilling packages that target other distros easier.
59 ln -s $out/bin/${mainProgram} $out/bin/${mainProgram}-xslt
60 ''
61 + lib.optionalString (versionAtLeast finalAttrs.version "11") ''
62 mv lib $out/share/java
63 ''
64 + lib.optionalString (versionAtLeast finalAttrs.version "8") ''
65 makeWrapper ${lib.getExe jre} $out/bin/transform \
66 --add-flags "-cp $out/share/java/${jar'}.jar net.sf.saxon.Transform"
67
68 makeWrapper ${lib.getExe jre} $out/bin/query \
69 --add-flags "-cp $out/share/java/${jar'}.jar net.sf.saxon.Query"
70 ''
71 + "runHook postInstall";
72
73 passthru = lib.optionalAttrs (updateScript != null) {
74 inherit updateScript;
75 };
76
77 meta = {
78 inherit description license mainProgram;
79 homepage =
80 if versionAtLeast finalAttrs.version "11" then
81 "https://www.saxonica.com/products/latest.xml"
82 else
83 "https://www.saxonica.com/products/archive.xml";
84 sourceProvenance = with lib.sourceTypes; [ binaryBytecode ];
85 maintainers = with lib.maintainers; [ rvl ];
86 platforms = lib.platforms.all;
87 };
88 }
89 );
90
91 # Saxon release zipfiles and tags often use dashes instead of dots.
92 dashify = version: concatStringsSep "-" (splitVersion version);
93
94 # SaxonJ-HE release files are pushed to the Saxon-HE GitHub repository.
95 # They are also available from Maven.
96 #
97 # Older releases were uploaded to SourceForge. They are also
98 # available from the Saxon-Archive GitHub repository.
99 github = {
100 updateScript =
101 version:
102 genericUpdater {
103 versionLister = writeShellScript "saxon-he-versionLister" ''
104 export PATH="${
105 lib.makeBinPath [
106 common-updater-scripts
107 gnused
108 ]
109 }:$PATH"
110 major_ver="${major version}"
111 list-git-tags --url="https://github.com/Saxonica/Saxon-HE.git" \
112 | sed -En \
113 -e "s/SaxonHE([0-9]+)-([0-9]+)/\1.\2/" \
114 -e "/^''${major_ver:-[0-9]+}\./p"
115 '';
116 };
117
118 downloadUrl =
119 version:
120 let
121 tag = "SaxonHE${dashify version}";
122 filename = "${major version}/Java/${tag}J.zip";
123 in
124 "https://raw.githubusercontent.com/Saxonica/Saxon-HE/${tag}/${filename}";
125 };
126
127in
128{
129 saxon = common rec {
130 pname = "saxon";
131 version = "6.5.3";
132 src = fetchurl {
133 url = "mirror://sourceforge/saxon/OldFiles/${version}/saxon${
134 builtins.replaceStrings [ "." ] [ "_" ] version
135 }.zip";
136 hash = "sha256-Q28wzqyUCPBJ2C3a8acdG2lmeee8GeEAgg9z8oUfvlA=";
137 };
138 description = "XSLT 1.0 processor";
139 # https://saxon.sourceforge.net/saxon6.5.3/conditions.html
140 license = lib.licenses.mpl10;
141 java = jre8;
142 };
143
144 saxonb_8_8 = common rec {
145 pname = "saxonb";
146 version = "8.8";
147 jar = "saxon8";
148 src = fetchurl {
149 url = "mirror://sourceforge/saxon/saxonb${dashify version}j.zip";
150 hash = "sha256-aOk+BB5kAbZElAifVG+AP1bo7Se3patzISA40bzLf5U=";
151 };
152 description = "Complete and conformant processor of XSLT 2.0, XQuery 1.0, and XPath 2.0";
153 java = jre8;
154 };
155
156 saxonb_9_1 = common rec {
157 pname = "saxonb";
158 version = "9.1.0.8";
159 jar = "saxon9";
160 src = fetchurl {
161 url = "mirror://sourceforge/saxon/Saxon-B/${version}/saxonb${dashify version}j.zip";
162 sha256 = "1d39jdnwr3v3pzswm81zry6yikqlqy9dp2l2wmpqdiw00r5drg4j";
163 };
164 description = "Complete and conformant processor of XSLT 2.0, XQuery 1.0, and XPath 2.0";
165 };
166
167 # Saxon-HE (home edition) replaces Saxon-B as the open source
168 # version of the Saxon XSLT and XQuery processor.
169 saxon_9-he = common rec {
170 pname = "saxon-he";
171 version = "9.9.0.1";
172 jar = "saxon9he";
173 src = fetchurl {
174 url = "mirror://sourceforge/saxon/Saxon-HE/${majorMinor version}/SaxonHE${dashify version}J.zip";
175 sha256 = "1inxd7ia7rl9fxfrw8dy9sb7rqv76ipblaki5262688wf2dscs60";
176 };
177 description = "Processor for XSLT 3.0, XPath 2.0 and 3.1, and XQuery 3.1";
178 };
179
180 saxon_11-he = common rec {
181 pname = "saxon-he";
182 version = "11.7";
183 jar = "saxon-he-${version}";
184 src = fetchurl {
185 url = github.downloadUrl version;
186 sha256 = "MGzhUW9ZLVvTSqEdpAZWAiwTYxCZxbn26zESDmIe4Vo=";
187 };
188 updateScript = github.updateScript version;
189 description = "Processor for XSLT 3.0, XPath 2.0 and 3.1, and XQuery 3.1";
190 };
191
192 saxon_12-he = common rec {
193 pname = "saxon-he";
194 version = "12.9";
195 jar = "saxon-he-${version}";
196 src = fetchurl {
197 url = github.downloadUrl version;
198 hash = "sha256-8olb7zeUESxlChWL4nw5qG6IwXF+u44OiAZ9HwdjXRI=";
199 };
200 updateScript = github.updateScript version;
201 description = "Processor for XSLT 3.0, XPath 3.1, and XQuery 3.1";
202 };
203}