Skip to content

Instantly share code, notes, and snippets.

@tyrion
Created June 1, 2020 08:18
Show Gist options
  • Save tyrion/7be8fec894181e881b7b6803d5772b76 to your computer and use it in GitHub Desktop.
Save tyrion/7be8fec894181e881b7b6803d5772b76 to your computer and use it in GitHub Desktop.
JabRef
let
nixpkgs = import <nixpkgs> {};
pkgs = with nixpkgs; rec {
patched-ffmpeg = callPackage ./patched-ffmpeg.nix { };
jabref = callPackage ./jabref.nix { ffmpeg_2 = patched-ffmpeg; };
};
in pkgs
{ stdenv
, fetchurl
, makeWrapper
, dpkg
, autoPatchelfHook
, alsaLib
, cairo
, ffmpeg
, ffmpeg_2
, ffmpeg_4
, gdk-pixbuf
, glib
, glibc
, gtk2-x11
, gtk3-x11
, lib
, libbsd
, libglvnd
, xlibs
, zlib
}:
stdenv.mkDerivation rec {
name = "jabref-${version}";
version = "5.0";
src = fetchurl {
url = "https://github.com/JabRef/jabref/releases/download/v${version}/jabref_${version}-1_amd64.deb";
sha256 = "8ff14cc6a46ab1c9c8e65acdbada498c7ad5f4695d4cc58dc9be9f0a5d6a20f4";
};
nativeBuildInputs = [
dpkg
autoPatchelfHook
makeWrapper
];
buildInputs = [
alsaLib
cairo
ffmpeg
ffmpeg_2
ffmpeg_4
gdk-pixbuf
glib
glibc
gtk2-x11
gtk3-x11
libbsd
libglvnd
xlibs.libxcb
xlibs.libX11
xlibs.libXext
xlibs.libXrender
xlibs.libXi
xlibs.libXtst
zlib
];
unpackPhase = ''
mkdir -p $out
dpkg -x $src $out
cp -av $out/opt/jabref/* $out
rm -rf $out/opt
'';
patchPhase = ''
patchShebangs $out/lib/jabrefHost.py
substituteInPlace $out/lib/jabrefHost.py --replace "bin/JabRef" "bin/JabRefWrapper"
substituteInPlace $out/lib/jabref-JabRef.desktop \
--replace "/opt/jabref" $out \
--replace "bin/JabRef" "bin/JabRefWrapper"
for f in $out/lib/native-messaging-host/*/*.json; do
substituteInPlace $f --replace "/opt/jabref" $out
done
'';
installPhase = ''
makeWrapper $out/bin/JabRef $out/bin/JabRefWrapper \
--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath buildInputs}
mkdir -p $out/share/applications
mv $out/lib/jabref-JabRef.desktop $out/share/applications
'';
meta = with stdenv.lib; {
homepage = https://www.jabref.org/;
description = "Graphical Java application for managing BibTeX and biblatex (.bib) databases";
platforms = platforms.linux;
};
}
{ stdenv
, ffmpeg_2
}:
stdenv.mkDerivation rec {
name = "patched-ffmpeg";
unpackPhase = "true";
installPhase = ''
mkdir -p $out/lib
cd ${ffmpeg_2.out}/lib
cp libavcodec.so.56 $out/lib/libavcodec.so.54
cp libavformat.so.56 $out/lib/libavformat.so.54
for f in *; do
ext=''${f#*.}
cp $f "$out/lib/''${f%.$ext}-ffmpeg.$ext"
done
'';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment