at master 6.0 kB view raw
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 = with lib; { 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 sourceTypes; [ binaryBytecode ]; 85 maintainers = with maintainers; [ rvl ]; 86 platforms = 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/saxon${dashify version}.zip"; 134 hash = "sha256-Q28wzqyUCPBJ2C3a8acdG2lmeee8GeEAgg9z8oUfvlA="; 135 }; 136 description = "XSLT 1.0 processor"; 137 # https://saxon.sourceforge.net/saxon6.5.3/conditions.html 138 license = lib.licenses.mpl10; 139 java = jre8; 140 }; 141 142 saxonb_8_8 = common rec { 143 pname = "saxonb"; 144 version = "8.8"; 145 jar = "saxon8"; 146 src = fetchurl { 147 url = "mirror://sourceforge/saxon/saxonb${dashify version}j.zip"; 148 hash = "sha256-aOk+BB5kAbZElAifVG+AP1bo7Se3patzISA40bzLf5U="; 149 }; 150 description = "Complete and conformant processor of XSLT 2.0, XQuery 1.0, and XPath 2.0"; 151 java = jre8; 152 }; 153 154 saxonb_9_1 = common rec { 155 pname = "saxonb"; 156 version = "9.1.0.8"; 157 jar = "saxon9"; 158 src = fetchurl { 159 url = "mirror://sourceforge/saxon/Saxon-B/${version}/saxonb${dashify version}j.zip"; 160 sha256 = "1d39jdnwr3v3pzswm81zry6yikqlqy9dp2l2wmpqdiw00r5drg4j"; 161 }; 162 description = "Complete and conformant processor of XSLT 2.0, XQuery 1.0, and XPath 2.0"; 163 }; 164 165 # Saxon-HE (home edition) replaces Saxon-B as the open source 166 # version of the Saxon XSLT and XQuery processor. 167 saxon_9-he = common rec { 168 pname = "saxon-he"; 169 version = "9.9.0.1"; 170 jar = "saxon9he"; 171 src = fetchurl { 172 url = "mirror://sourceforge/saxon/Saxon-HE/${majorMinor version}/SaxonHE${dashify version}J.zip"; 173 sha256 = "1inxd7ia7rl9fxfrw8dy9sb7rqv76ipblaki5262688wf2dscs60"; 174 }; 175 description = "Processor for XSLT 3.0, XPath 2.0 and 3.1, and XQuery 3.1"; 176 }; 177 178 saxon_11-he = common rec { 179 pname = "saxon-he"; 180 version = "11.7"; 181 jar = "saxon-he-${version}"; 182 src = fetchurl { 183 url = github.downloadUrl version; 184 sha256 = "MGzhUW9ZLVvTSqEdpAZWAiwTYxCZxbn26zESDmIe4Vo="; 185 }; 186 updateScript = github.updateScript version; 187 description = "Processor for XSLT 3.0, XPath 2.0 and 3.1, and XQuery 3.1"; 188 }; 189 190 saxon_12-he = common rec { 191 pname = "saxon-he"; 192 version = "12.9"; 193 jar = "saxon-he-${version}"; 194 src = fetchurl { 195 url = github.downloadUrl version; 196 hash = "sha256-8olb7zeUESxlChWL4nw5qG6IwXF+u44OiAZ9HwdjXRI="; 197 }; 198 updateScript = github.updateScript version; 199 description = "Processor for XSLT 3.0, XPath 3.1, and XQuery 3.1"; 200 }; 201}