Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 149 lines 4.1 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchFromGitHub, 5 wrapGAppsHook3, 6 makeDesktopItem, 7 copyDesktopItems, 8 unzip, 9 xdg-utils, 10 gtk3, 11 jdk, 12 gradle_8, 13 python3, 14}: 15let 16 # "Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0." 17 gradle = gradle_8; 18in 19stdenv.mkDerivation rec { 20 version = "5.13"; 21 pname = "jabref"; 22 23 src = fetchFromGitHub { 24 owner = "JabRef"; 25 repo = "jabref"; 26 rev = "v${version}"; 27 hash = "sha256-inE2FXAaEEiq7343KwtjEiTEHLtn01AzP0foTpsLoAw="; 28 fetchSubmodules = true; 29 }; 30 31 desktopItems = [ 32 (makeDesktopItem { 33 comment = meta.description; 34 name = "JabRef"; 35 desktopName = "JabRef"; 36 genericName = "Bibliography manager"; 37 categories = [ "Office" ]; 38 icon = "jabref"; 39 exec = "JabRef %U"; 40 startupWMClass = "org.jabref.gui.JabRefGUI"; 41 mimeTypes = [ "text/x-bibtex" ]; 42 }) 43 ]; 44 45 mitmCache = gradle.fetchDeps { 46 inherit pname; 47 data = ./deps.json; 48 }; 49 50 postPatch = '' 51 # Disable update check 52 substituteInPlace src/main/java/org/jabref/preferences/JabRefPreferences.java \ 53 --replace 'VERSION_CHECK_ENABLED, Boolean.TRUE' \ 54 'VERSION_CHECK_ENABLED, Boolean.FALSE' 55 56 # Find OpenOffice/LibreOffice binary 57 substituteInPlace src/main/java/org/jabref/logic/openoffice/OpenOfficePreferences.java \ 58 --replace '/usr' '/run/current-system/sw' 59 ''; 60 61 nativeBuildInputs = [ 62 jdk 63 gradle 64 wrapGAppsHook3 65 copyDesktopItems 66 unzip 67 ]; 68 69 buildInputs = [ 70 gtk3 71 python3 72 ]; 73 74 gradleFlags = [ 75 "-PprojVersion=${version}" 76 "-Dorg.gradle.java.home=${jdk}" 77 ]; 78 79 preBuild = '' 80 gradleFlagsArray+=(-PprojVersionInfo="${version} NixOS") 81 ''; 82 83 dontWrapGApps = true; 84 85 installPhase = '' 86 runHook preInstall 87 88 install -dm755 $out/share/java/jabref 89 install -Dm644 LICENSE $out/share/licenses/jabref/LICENSE 90 install -Dm644 src/main/resources/icons/jabref.svg $out/share/pixmaps/jabref.svg 91 92 # script to support browser extensions 93 install -Dm755 buildres/linux/jabrefHost.py $out/lib/jabrefHost.py 94 patchShebangs $out/lib/jabrefHost.py 95 install -Dm644 buildres/linux/native-messaging-host/firefox/org.jabref.jabref.json $out/lib/mozilla/native-messaging-hosts/org.jabref.jabref.json 96 sed -i -e "s|/opt/jabref|$out|" $out/lib/mozilla/native-messaging-hosts/org.jabref.jabref.json 97 98 # Resources in the jar can't be found, workaround copied from AUR 99 cp -r build/resources $out/share/java/jabref 100 101 tar xf build/distributions/JabRef-${version}.tar -C $out --strip-components=1 102 103 DEFAULT_JVM_OPTS=$(sed -n -E "s/^DEFAULT_JVM_OPTS='(.*)'$/\1/p" $out/bin/JabRef | sed -e "s|\$APP_HOME|$out|g" -e 's/"//g') 104 105 # Temp fix: openjfx doesn't build with webkit 106 unzip $out/lib/javafx-web-*-*.jar libjfxwebkit.so -d $out/lib/ 107 108 runHook postInstall 109 ''; 110 111 postFixup = '' 112 rm $out/bin/* 113 114 # put this in postFixup because some gappsWrapperArgs are generated in gappsWrapperArgsHook in preFixup 115 makeWrapper ${jdk}/bin/java $out/bin/JabRef \ 116 "''${gappsWrapperArgs[@]}" \ 117 --suffix PATH : ${lib.makeBinPath [ xdg-utils ]} \ 118 --add-flags "-Djava.library.path=$out/lib/ --patch-module org.jabref=$out/share/java/jabref/resources/main" \ 119 --add-flags "$DEFAULT_JVM_OPTS" 120 121 # lowercase alias (for convenience and required for browser extensions) 122 ln -sf $out/bin/JabRef $out/bin/jabref 123 ''; 124 125 gradleUpdateScript = '' 126 runHook preBuild 127 128 gradle nixDownloadDeps -Dos.arch=amd64 129 gradle nixDownloadDeps -Dos.arch=aarch64 130 ''; 131 132 meta = with lib; { 133 description = "Open source bibliography reference manager"; 134 homepage = "https://www.jabref.org"; 135 sourceProvenance = with sourceTypes; [ 136 fromSource 137 binaryBytecode # source bundles dependencies as jars 138 binaryNativeCode # source bundles dependencies as jars 139 ]; 140 license = licenses.mit; 141 platforms = [ 142 "x86_64-linux" 143 "aarch64-linux" 144 ]; 145 maintainers = with maintainers; [ 146 linsui 147 ]; 148 }; 149}