20 snapshot = "2.2.1-SNAPSHOT";
21 pin = "2.2.1-20230117.075740-16";
24 jackson-datatype-jsr310 = fetchurl {
25 url = "https://repo1.maven.org/maven2/com/fasterxml/jackson/datatype/jackson-datatype-jsr310/2.15.3/jackson-datatype-jsr310-2.15.3.jar";
26 hash = "sha256-vqHXgAnrxOXVSRij967F2p+9CfZiwZGiF//PN+hSfF4=";
29 stdenv.mkDerivation rec {
33 src = fetchFromGitHub {
37 hash = "sha256-+ltd9hItmMkEpKzX6TFfFy5fiOkLBK/tQNsh8OVDeoc=";
38 fetchSubmodules = true;
43 comment = meta.description;
45 desktopName = "JabRef";
46 genericName = "Bibliography manager";
47 categories = [ "Office" ];
50 startupWMClass = "org.jabref.gui.JabRefMain";
51 mimeTypes = [ "text/x-bibtex" ];
55 deps = stdenv.mkDerivation {
56 pname = "${pname}-deps";
57 inherit src version postPatch;
59 nativeBuildInputs = [ gradle perl ];
61 export GRADLE_USER_HOME=$(mktemp -d)
62 gradle --no-daemon downloadDependencies -Dos.arch=amd64
63 gradle --no-daemon downloadDependencies -Dos.arch=aarch64
65 # perl code mavenizes pathes (com.squareup.okio/okio/1.13.0/a9283170b7305c8d92d25aff02a6ab7e45d06cbe/okio-1.13.0.jar -> com/squareup/okio/okio/1.13.0/okio-1.13.0.jar)
67 find $GRADLE_USER_HOME/caches/modules-2/ -type f -regex '.*\.\(jar\|pom\)' \
68 | perl -pe 's#(.*/([^/]+)/([^/]+)/([^/]+)/[0-9a-f]{30,40}/([^/\s]+))$# ($x = $2) =~ tr|\.|/|; "install -Dm444 $1 \$out/$x/$3/$4/''${\($5 =~ s/-jvm//r)}" #e' \
70 mv $out/com/tobiasdiez/easybind/${versionReplace.easybind.pin} \
71 $out/com/tobiasdiez/easybind/${versionReplace.easybind.snapshot}
72 # This is used but not cached by Gradle.
73 cp ${jackson-datatype-jsr310} $out/com/fasterxml/jackson/datatype/jackson-datatype-jsr310/2.15.3/jackson-datatype-jsr310-2.15.3.jar
75 # Don't move info to share/
76 forceShare = [ "dummy" ];
77 outputHashMode = "recursive";
78 outputHash = "sha256-baP/zNgcc6oYwwbWvT7ontULcKKCw0rTQRkdZMgcWfY=";
83 substituteInPlace build.gradle \
84 --replace 'com.tobiasdiez:easybind:${versionReplace.easybind.snapshot}' \
85 'com.tobiasdiez:easybind:${versionReplace.easybind.pin}'
87 # Disable update check
88 substituteInPlace src/main/java/org/jabref/preferences/JabRefPreferences.java \
89 --replace 'VERSION_CHECK_ENABLED, Boolean.TRUE' \
90 'VERSION_CHECK_ENABLED, Boolean.FALSE'
92 # Find OpenOffice/LibreOffice binary
93 substituteInPlace src/main/java/org/jabref/logic/openoffice/OpenOfficePreferences.java \
94 --replace '/usr' '/run/current-system/sw'
96 # Don't fetch predatory sources. These source are fetched from online webpages.
97 sed -i -e '/new PJSource/,/);/c);' src/main/java/org/jabref/logic/journals/predatory/PredatoryJournalListCrawler.java
99 # Add back downloadDependencies task for deps download which is removed upstream in https://github.com/JabRef/jabref/pull/10326
100 cat <<EOF >> build.gradle
101 task downloadDependencies {
102 description "Pre-downloads *most* dependencies"
104 configurations.getAsMap().each { name, config ->
105 println "Retrieving dependencies for $name"
109 // some cannot be resolved, just log them
110 project.logger.info e.message
119 # Use the local packages from -deps
120 sed -i -e '/repositories {/a maven { url uri("${deps}") }' \
125 nativeBuildInputs = [
141 export GRADLE_USER_HOME=$(mktemp -d)
145 -PprojVersion="${version}" \
146 -PprojVersionInfo="${version} NixOS" \
147 -Dorg.gradle.java.home=${jdk} \
153 dontWrapGApps = true;
158 install -dm755 $out/share/java/jabref
159 install -Dm644 LICENSE $out/share/licenses/jabref/LICENSE
160 install -Dm644 src/main/resources/icons/jabref.svg $out/share/pixmaps/jabref.svg
162 # script to support browser extensions
163 install -Dm755 buildres/linux/jabrefHost.py $out/lib/jabrefHost.py
164 patchShebangs $out/lib/jabrefHost.py
165 install -Dm644 buildres/linux/native-messaging-host/firefox/org.jabref.jabref.json $out/lib/mozilla/native-messaging-hosts/org.jabref.jabref.json
166 sed -i -e "s|/opt/jabref|$out|" $out/lib/mozilla/native-messaging-hosts/org.jabref.jabref.json
168 # Resources in the jar can't be found, workaround copied from AUR
169 cp -r build/resources $out/share/java/jabref
171 tar xf build/distributions/JabRef-${version}.tar -C $out --strip-components=1
173 # workaround for https://github.com/NixOS/nixpkgs/issues/162064
174 unzip $out/lib/javafx-web-*-*.jar libjfxwebkit.so -d $out/lib/
176 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')
184 # put this in postFixup because some gappsWrapperArgs are generated in gappsWrapperArgsHook in preFixup
185 makeWrapper ${jdk}/bin/java $out/bin/JabRef \
186 "''${gappsWrapperArgs[@]}" \
187 --suffix PATH : ${lib.makeBinPath [ xdg-utils ]} \
188 --add-flags "-Djava.library.path=$out/lib/ --patch-module org.jabref=$out/share/java/jabref/resources/main" \
189 --add-flags "$DEFAULT_JVM_OPTS"
191 # lowercase alias (for convenience and required for browser extensions)
192 ln -sf $out/bin/JabRef $out/bin/jabref
196 description = "Open source bibliography reference manager";
197 homepage = "https://www.jabref.org";
198 sourceProvenance = with sourceTypes; [
200 binaryBytecode # source bundles dependencies as jars
201 binaryNativeCode # source bundles dependencies as jars
203 license = licenses.mit;
204 platforms = [ "x86_64-linux" "aarch64-linux" ];
205 maintainers = with maintainers; [ gebner linsui ];