Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at flake-libs 183 lines 5.3 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchurl, 5 unzip, 6 jre, 7 jre8, 8 genericUpdater, 9 writeShellScript, 10 common-updater-scripts, 11 gnused, 12}: 13 14let 15 inherit (lib.versions) major majorMinor splitVersion; 16 inherit (lib.strings) concatStringsSep versionAtLeast; 17 18 common = 19 { 20 pname, 21 version, 22 src, 23 description, 24 java ? jre, 25 prog ? null, 26 jar ? null, 27 license ? lib.licenses.mpl20, 28 updateScript ? null, 29 }: 30 stdenv.mkDerivation ( 31 finalAttrs: 32 let 33 mainProgram = if prog == null then pname else prog; 34 jar' = if jar == null then pname else jar; 35 in 36 { 37 inherit pname version src; 38 39 nativeBuildInputs = [ unzip ]; 40 41 buildCommand = '' 42 unzip $src -d $out 43 mkdir -p $out/bin $out/share $out/share/java 44 cp -s "$out"/*.jar "$out/share/java/" # */ 45 rm -rf $out/notices 46 mv $out/doc $out/share 47 cat > $out/bin/${mainProgram} <<EOF 48 #! $shell 49 export JAVA_HOME=${jre} 50 exec ${jre}/bin/java -jar $out/${jar'}.jar "\$@" 51 EOF 52 chmod a+x $out/bin/${mainProgram} 53 ''; 54 55 passthru = lib.optionalAttrs (updateScript != null) { 56 inherit updateScript; 57 }; 58 59 meta = with lib; { 60 inherit description license mainProgram; 61 homepage = 62 if versionAtLeast finalAttrs.version "11" then 63 "https://www.saxonica.com/products/latest.xml" 64 else 65 "https://www.saxonica.com/products/archive.xml"; 66 sourceProvenance = with sourceTypes; [ binaryBytecode ]; 67 maintainers = with maintainers; [ rvl ]; 68 platforms = platforms.all; 69 }; 70 } 71 ); 72 73 # Saxon release zipfiles and tags often use dashes instead of dots. 74 dashify = version: concatStringsSep "-" (splitVersion version); 75 76 # SaxonJ-HE release files are pushed to the Saxon-HE GitHub repository. 77 # They are also available from Maven. 78 # 79 # Older releases were uploaded to SourceForge. They are also 80 # available from the Saxon-Archive GitHub repository. 81 github = { 82 updateScript = 83 version: 84 genericUpdater { 85 versionLister = writeShellScript "saxon-he-versionLister" '' 86 export PATH="${ 87 lib.makeBinPath [ 88 common-updater-scripts 89 gnused 90 ] 91 }:$PATH" 92 major_ver="${major version}" 93 list-git-tags --url="https://github.com/Saxonica/Saxon-HE.git" \ 94 | sed -En \ 95 -e "s/SaxonHE([0-9]+)-([0-9]+)/\1.\2/" \ 96 -e "/^''${major_ver:-[0-9]+}\./p" 97 ''; 98 }; 99 100 downloadUrl = 101 version: 102 let 103 tag = "SaxonHE${dashify version}"; 104 filename = "${major version}/Java/${tag}J.zip"; 105 in 106 "https://raw.githubusercontent.com/Saxonica/Saxon-HE/${tag}/${filename}"; 107 }; 108 109in 110{ 111 saxon = common rec { 112 pname = "saxon"; 113 version = "6.5.3"; 114 src = fetchurl { 115 url = "mirror://sourceforge/saxon/saxon${dashify version}.zip"; 116 sha256 = "0l5y3y2z4wqgh80f26dwwxwncs8v3nkz3nidv14z024lmk730vs3"; 117 }; 118 description = "XSLT 1.0 processor"; 119 # https://saxon.sourceforge.net/saxon6.5.3/conditions.html 120 license = lib.licenses.mpl10; 121 java = jre8; 122 }; 123 124 saxonb_8_8 = common rec { 125 pname = "saxonb"; 126 version = "8.8"; 127 jar = "saxon8"; 128 src = fetchurl { 129 url = "mirror://sourceforge/saxon/saxonb${dashify version}j.zip"; 130 sha256 = "15bzrfyd2f1045rsp9dp4znyhmizh1pm97q8ji2bc0b43q23xsb8"; 131 }; 132 description = "Complete and conformant processor of XSLT 2.0, XQuery 1.0, and XPath 2.0"; 133 java = jre8; 134 }; 135 136 saxonb_9_1 = common rec { 137 pname = "saxonb"; 138 version = "9.1.0.8"; 139 jar = "saxon9"; 140 src = fetchurl { 141 url = "mirror://sourceforge/saxon/Saxon-B/${version}/saxonb${dashify version}j.zip"; 142 sha256 = "1d39jdnwr3v3pzswm81zry6yikqlqy9dp2l2wmpqdiw00r5drg4j"; 143 }; 144 description = "Complete and conformant processor of XSLT 2.0, XQuery 1.0, and XPath 2.0"; 145 }; 146 147 # Saxon-HE (home edition) replaces Saxon-B as the open source 148 # version of the Saxon XSLT and XQuery processor. 149 saxon_9-he = common rec { 150 pname = "saxon-he"; 151 version = "9.9.0.1"; 152 jar = "saxon9he"; 153 src = fetchurl { 154 url = "mirror://sourceforge/saxon/Saxon-HE/${majorMinor version}/SaxonHE${dashify version}J.zip"; 155 sha256 = "1inxd7ia7rl9fxfrw8dy9sb7rqv76ipblaki5262688wf2dscs60"; 156 }; 157 description = "Processor for XSLT 3.0, XPath 2.0 and 3.1, and XQuery 3.1"; 158 }; 159 160 saxon_11-he = common rec { 161 pname = "saxon-he"; 162 version = "11.6"; 163 jar = "saxon-he-${version}"; 164 src = fetchurl { 165 url = github.downloadUrl version; 166 sha256 = "/AVX5mtZSO6Is19t3+FlEvtIBsnwB3MIWAPCht8Aqnw="; 167 }; 168 updateScript = github.updateScript version; 169 description = "Processor for XSLT 3.0, XPath 2.0 and 3.1, and XQuery 3.1"; 170 }; 171 172 saxon_12-he = common rec { 173 pname = "saxon-he"; 174 version = "12.6"; 175 jar = "saxon-he-${version}"; 176 src = fetchurl { 177 url = github.downloadUrl version; 178 hash = "sha256-y7ZlfaBhwVVHatnkOjVkpMySjUlR6+7S6v5aCqdOKu4="; 179 }; 180 updateScript = github.updateScript version; 181 description = "Processor for XSLT 3.0, XPath 3.1, and XQuery 3.1"; 182 }; 183}