Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 124 lines 2.8 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchFromGitHub, 5 ant, 6 jdk11, 7 makeWrapper, 8 stripJavaArchivesHook, 9 testers, 10}: 11 12let 13 pname = "textidote"; 14 version = "0.8.3"; 15 # We can't compile with > Java 11 yet because that's the last version that supports targeting Java 6 16 jdk = jdk11; 17 18 # Manually create a fixed-output derivation to populate the dependencies for the rest of the build 19 # The Ant buildscript downloads dependencies and stores them alongside the source code in a non-standard way 20 # https://github.com/sylvainhalle/AntRun 21 populated-src = stdenv.mkDerivation { 22 pname = "textidote-populated-src"; 23 inherit version; 24 25 src = fetchFromGitHub { 26 owner = "sylvainhalle"; 27 repo = "textidote"; 28 rev = "refs/tags/v${version}"; 29 hash = "sha256-QMSoxk5jDn6qsdxffXJ/S4eTIzLjJdAEbdaK8MZIavI="; 30 }; 31 32 nativeBuildInputs = [ 33 ant 34 jdk 35 ]; 36 37 # Only run dependency-downloading tasks here to pre-download the dependencies for later 38 buildPhase = '' 39 runHook preBuild 40 41 ant download-deps junit jacoco 42 43 runHook postBuild 44 ''; 45 46 # Copy the entire directory to the output including sources and resolved dependencies 47 installPhase = '' 48 runHook preInstall 49 50 cp -a . $out 51 52 runHook postInstall 53 ''; 54 55 dontFixup = true; 56 outputHashMode = "recursive"; 57 outputHash = "sha256-LrFClt8zN/ma42+Yoqwoy03TCuC3JfAeb02vehkljBo="; 58 }; 59in 60stdenv.mkDerivation (finalAttrs: { 61 inherit pname version; 62 63 src = populated-src; 64 65 nativeBuildInputs = [ 66 ant 67 makeWrapper 68 stripJavaArchivesHook 69 ]; 70 71 buildInputs = [ 72 jdk 73 ]; 74 75 # `javac` encoding only defaults to UTF-8 after Java 18 76 env.ANT_OPTS = "-Dfile.encoding=utf8"; 77 78 buildPhase = '' 79 runHook preBuild 80 81 ant jar 82 83 runHook postBuild 84 ''; 85 86 doCheck = true; 87 checkPhase = '' 88 runHook preCheck 89 90 ant test 91 92 runHook postCheck 93 ''; 94 95 # Recreates the wrapper from the `.deb` 96 # The `.deb` seems to be manually created for every release; there's no script in the repo 97 installPhase = '' 98 runHook preInstall 99 100 install -Dm644 textidote.jar $out/share/textidote/textidote.jar 101 102 makeWrapper ${lib.getExe jdk} $out/bin/textidote \ 103 --add-flags "-jar $out/share/textidote/textidote.jar --name textidote" 104 105 runHook postInstall 106 ''; 107 108 passthru.tests = { 109 version = testers.testVersion { 110 package = finalAttrs.finalPackage; 111 version = "TeXtidote v${finalAttrs.version}"; 112 }; 113 }; 114 115 meta = { 116 homepage = "https://sylvainhalle.github.io/textidote/"; 117 downloadPage = "https://github.com/sylvainhalle/textidote/releases"; 118 description = "Correction tool for LaTeX documents"; 119 license = lib.licenses.gpl3Only; 120 maintainers = with lib.maintainers; [ magneticflux- ]; 121 mainProgram = "textidote"; 122 inherit (jdk.meta) platforms; 123 }; 124})