2022-07-18 16:21:45 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
2023-10-09 19:29:22 +00:00
|
|
|
, fetchurl
|
2022-07-18 16:21:45 +00:00
|
|
|
, fetchFromGitHub
|
2022-08-21 13:32:41 +00:00
|
|
|
, wrapGAppsHook
|
2022-07-18 16:21:45 +00:00
|
|
|
, makeDesktopItem
|
|
|
|
, copyDesktopItems
|
|
|
|
, unzip
|
|
|
|
, xdg-utils
|
2022-08-21 13:32:41 +00:00
|
|
|
, gtk3
|
2022-07-18 16:21:45 +00:00
|
|
|
, jdk
|
|
|
|
, gradle
|
|
|
|
, perl
|
2023-10-09 19:29:22 +00:00
|
|
|
, python3
|
2022-07-18 16:21:45 +00:00
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-03-15 16:39:30 +00:00
|
|
|
let
|
|
|
|
versionReplace = {
|
|
|
|
easybind = {
|
|
|
|
snapshot = "2.2.1-SNAPSHOT";
|
|
|
|
pin = "2.2.1-20230117.075740-16";
|
|
|
|
};
|
|
|
|
afterburner = {
|
2023-10-09 19:29:22 +00:00
|
|
|
snapshot = "1.1.0-SNAPSHOT";
|
|
|
|
pin = "1.1.0-20221226.155809-7";
|
2023-03-15 16:39:30 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
in
|
2020-04-24 23:36:52 +00:00
|
|
|
stdenv.mkDerivation rec {
|
2023-10-09 19:29:22 +00:00
|
|
|
version = "5.10";
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "jabref";
|
|
|
|
|
2022-07-18 16:21:45 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "JabRef";
|
|
|
|
repo = "jabref";
|
|
|
|
rev = "v${version}";
|
2023-10-09 19:29:22 +00:00
|
|
|
hash = "sha256-Yj4mjXOZVM0dKcMfTjmnZs/kIs8AR0KJ9HKlyPM96j8=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2022-07-18 16:21:45 +00:00
|
|
|
desktopItems = [
|
|
|
|
(makeDesktopItem {
|
|
|
|
comment = meta.description;
|
2023-08-04 22:07:22 +00:00
|
|
|
name = "JabRef";
|
2022-07-18 16:21:45 +00:00
|
|
|
desktopName = "JabRef";
|
|
|
|
genericName = "Bibliography manager";
|
|
|
|
categories = [ "Office" ];
|
|
|
|
icon = "jabref";
|
2023-08-04 22:07:22 +00:00
|
|
|
exec = "JabRef %U";
|
2022-09-30 11:47:45 +00:00
|
|
|
startupWMClass = "org.jabref.gui.JabRefMain";
|
|
|
|
mimeTypes = [ "text/x-bibtex" ];
|
2022-07-18 16:21:45 +00:00
|
|
|
})
|
|
|
|
];
|
2020-11-21 19:51:51 +00:00
|
|
|
|
2023-10-09 19:29:22 +00:00
|
|
|
deps =
|
|
|
|
let
|
|
|
|
javafx-web = fetchurl {
|
|
|
|
url = "https://repo1.maven.org/maven2/org/openjfx/javafx-web/20/javafx-web-20.jar";
|
|
|
|
hash = "sha256-qRtVN34KURlVM5Ie/x25IfKsKsUcux7V2m3LML74G/s=";
|
|
|
|
};
|
|
|
|
in
|
|
|
|
stdenv.mkDerivation {
|
|
|
|
pname = "${pname}-deps";
|
|
|
|
inherit src version postPatch;
|
|
|
|
|
|
|
|
nativeBuildInputs = [ gradle perl ];
|
|
|
|
buildPhase = ''
|
|
|
|
export GRADLE_USER_HOME=$(mktemp -d)
|
|
|
|
gradle --no-daemon downloadDependencies -Dos.arch=amd64
|
|
|
|
gradle --no-daemon downloadDependencies -Dos.arch=aarch64
|
|
|
|
'';
|
|
|
|
# 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)
|
|
|
|
installPhase = ''
|
|
|
|
find $GRADLE_USER_HOME/caches/modules-2 -type f -regex '.*\.\(jar\|pom\)' \
|
|
|
|
| perl -pe 's#(.*/([^/]+)/([^/]+)/([^/]+)/[0-9a-f]{30,40}/([^/\s]+))$# ($x = $2) =~ tr|\.|/|; "install -Dm444 $1 \$out/$x/$3/$4/''${\($5 =~ s/-jvm//r)}" #e' \
|
|
|
|
| sh
|
|
|
|
mv $out/org/jabref/afterburner.fx/${versionReplace.afterburner.pin} \
|
|
|
|
$out/org/jabref/afterburner.fx/${versionReplace.afterburner.snapshot}
|
|
|
|
mv $out/com/tobiasdiez/easybind/${versionReplace.easybind.pin} \
|
|
|
|
$out/com/tobiasdiez/easybind/${versionReplace.easybind.snapshot}
|
|
|
|
# This jar is required but not used or cached for unknown reason.
|
|
|
|
cp ${javafx-web} $out/org/openjfx/javafx-web/20/javafx-web-20.jar
|
|
|
|
'';
|
|
|
|
# Don't move info to share/
|
|
|
|
forceShare = [ "dummy" ];
|
|
|
|
outputHashMode = "recursive";
|
|
|
|
outputHash = "sha256-XswHEKjzErL+znau/F6mTORVJlFSgVuT0svK29v5dEU=";
|
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-03-15 16:39:30 +00:00
|
|
|
postPatch = ''
|
|
|
|
# Pin the version
|
|
|
|
substituteInPlace build.gradle \
|
2023-10-09 19:29:22 +00:00
|
|
|
--replace 'org.jabref:afterburner.fx:${versionReplace.afterburner.snapshot}' \
|
|
|
|
'org.jabref:afterburner.fx:${versionReplace.afterburner.pin}' \
|
2023-03-15 16:39:30 +00:00
|
|
|
--replace 'com.tobiasdiez:easybind:${versionReplace.easybind.snapshot}' \
|
|
|
|
'com.tobiasdiez:easybind:${versionReplace.easybind.pin}'
|
2023-10-09 19:29:22 +00:00
|
|
|
|
|
|
|
# Disable update check
|
|
|
|
substituteInPlace src/main/java/org/jabref/preferences/JabRefPreferences.java \
|
|
|
|
--replace 'VERSION_CHECK_ENABLED, Boolean.TRUE' \
|
|
|
|
'VERSION_CHECK_ENABLED, Boolean.FALSE'
|
2023-03-15 16:39:30 +00:00
|
|
|
'';
|
|
|
|
|
2022-07-18 16:21:45 +00:00
|
|
|
preBuild = ''
|
|
|
|
# Include CSL styles and locales in our build
|
|
|
|
cp -r buildres/csl/* src/main/resources/
|
|
|
|
|
|
|
|
# Use the local packages from -deps
|
|
|
|
sed -i -e '/repositories {/a maven { url uri("${deps}") }' \
|
|
|
|
build.gradle \
|
|
|
|
buildSrc/build.gradle \
|
|
|
|
settings.gradle
|
2023-10-09 19:29:22 +00:00
|
|
|
|
|
|
|
# The `plugin {}` block can't resolve plugins from the deps repo
|
|
|
|
sed -e '/plugins {/,/^}/d' buildSrc/build.gradle > buildSrc/build.gradle.tmp
|
|
|
|
cat > buildSrc/build.gradle <<EOF
|
|
|
|
buildscript {
|
|
|
|
repositories { maven { url uri("${deps}") } }
|
|
|
|
dependencies { classpath 'org.openjfx:javafx-plugin:0.0.14' }
|
|
|
|
}
|
|
|
|
apply plugin: 'java'
|
|
|
|
apply plugin: 'org.openjfx.javafxplugin'
|
|
|
|
EOF
|
|
|
|
cat buildSrc/build.gradle.tmp >> buildSrc/build.gradle
|
2022-07-18 16:21:45 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
jdk
|
|
|
|
gradle
|
2022-08-21 13:32:41 +00:00
|
|
|
wrapGAppsHook
|
2022-07-18 16:21:45 +00:00
|
|
|
copyDesktopItems
|
|
|
|
unzip
|
|
|
|
];
|
|
|
|
|
2023-10-09 19:29:22 +00:00
|
|
|
buildInputs = [
|
|
|
|
gtk3
|
|
|
|
python3
|
|
|
|
];
|
2022-08-21 13:32:41 +00:00
|
|
|
|
2022-07-18 16:21:45 +00:00
|
|
|
buildPhase = ''
|
|
|
|
runHook preBuild
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-07-18 16:21:45 +00:00
|
|
|
export GRADLE_USER_HOME=$(mktemp -d)
|
|
|
|
gradle \
|
|
|
|
--offline \
|
|
|
|
--no-daemon \
|
|
|
|
-PprojVersion="${version}" \
|
|
|
|
-PprojVersionInfo="${version} NixOS" \
|
2022-09-30 11:47:45 +00:00
|
|
|
-Dorg.gradle.java.home=${jdk} \
|
2022-07-18 16:21:45 +00:00
|
|
|
assemble
|
|
|
|
|
|
|
|
runHook postBuild
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-09-30 11:47:45 +00:00
|
|
|
dontWrapGApps = true;
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
installPhase = ''
|
2022-07-18 16:21:45 +00:00
|
|
|
runHook preInstall
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-07-18 16:21:45 +00:00
|
|
|
install -dm755 $out/share/java/jabref
|
|
|
|
install -Dm644 LICENSE.md $out/share/licenses/jabref/LICENSE.md
|
|
|
|
install -Dm644 src/main/resources/icons/jabref.svg $out/share/pixmaps/jabref.svg
|
2020-11-21 19:51:51 +00:00
|
|
|
|
2022-07-18 16:21:45 +00:00
|
|
|
# script to support browser extensions
|
|
|
|
install -Dm755 buildres/linux/jabrefHost.py $out/lib/jabrefHost.py
|
2023-10-09 19:29:22 +00:00
|
|
|
patchShebangs $out/lib/jabrefHost.py
|
2022-07-18 16:21:45 +00:00
|
|
|
install -Dm644 buildres/linux/native-messaging-host/firefox/org.jabref.jabref.json $out/lib/mozilla/native-messaging-hosts/org.jabref.jabref.json
|
|
|
|
sed -i -e "s|/opt/jabref|$out|" $out/lib/mozilla/native-messaging-hosts/org.jabref.jabref.json
|
2020-11-21 19:51:51 +00:00
|
|
|
|
2022-07-18 16:21:45 +00:00
|
|
|
# Resources in the jar can't be found, workaround copied from AUR
|
|
|
|
cp -r build/resources $out/share/java/jabref
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-07-18 16:21:45 +00:00
|
|
|
tar xf build/distributions/JabRef-${version}.tar -C $out --strip-components=1
|
2023-03-15 16:39:30 +00:00
|
|
|
|
|
|
|
# workaround for https://github.com/NixOS/nixpkgs/issues/162064
|
2023-10-09 19:29:22 +00:00
|
|
|
unzip $out/lib/javafx-web-*-*.jar libjfxwebkit.so -d $out/lib/
|
2022-09-30 11:47:45 +00:00
|
|
|
|
|
|
|
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')
|
2023-08-04 22:07:22 +00:00
|
|
|
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
|
|
|
postFixup = ''
|
2022-09-30 11:47:45 +00:00
|
|
|
rm $out/bin/*
|
|
|
|
|
2023-08-04 22:07:22 +00:00
|
|
|
# put this in postFixup because some gappsWrapperArgs are generated in gappsWrapperArgsHook in preFixup
|
2022-09-30 11:47:45 +00:00
|
|
|
makeWrapper ${jdk}/bin/java $out/bin/JabRef \
|
|
|
|
"''${gappsWrapperArgs[@]}" \
|
|
|
|
--suffix PATH : ${lib.makeBinPath [ xdg-utils ]} \
|
|
|
|
--add-flags "-Djava.library.path=$out/lib/ --patch-module org.jabref=$out/share/java/jabref/resources/main" \
|
|
|
|
--add-flags "$DEFAULT_JVM_OPTS"
|
2020-11-21 19:51:51 +00:00
|
|
|
|
2022-07-18 16:21:45 +00:00
|
|
|
# lowercase alias (for convenience and required for browser extensions)
|
|
|
|
ln -sf $out/bin/JabRef $out/bin/jabref
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "Open source bibliography reference manager";
|
|
|
|
homepage = "https://www.jabref.org";
|
2022-07-18 16:21:45 +00:00
|
|
|
sourceProvenance = with sourceTypes; [
|
|
|
|
fromSource
|
2022-09-30 11:47:45 +00:00
|
|
|
binaryBytecode # source bundles dependencies as jars
|
|
|
|
binaryNativeCode # source bundles dependencies as jars
|
2022-07-18 16:21:45 +00:00
|
|
|
];
|
2023-01-11 07:51:40 +00:00
|
|
|
license = licenses.mit;
|
2022-07-18 16:21:45 +00:00
|
|
|
platforms = [ "x86_64-linux" "aarch64-linux" ];
|
|
|
|
maintainers = with maintainers; [ gebner linsui ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|