From 9d4fa42c9c309b0897a336a78d5db1627d0534e8 Mon Sep 17 00:00:00 2001 From: Gabriel Arazas Date: Sat, 18 Dec 2021 16:16:34 +0800 Subject: [PATCH] sioyek: init at 1.0.0 --- pkgs/default.nix | 1 + pkgs/sioyek.nix | 72 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 pkgs/sioyek.nix diff --git a/pkgs/default.nix b/pkgs/default.nix index 853cd307..1dc2b23a 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -11,4 +11,5 @@ pop-launcher-plugin-duckduckgo-bangs = pkgs.callPackage ./pop-launcher-plugin-duckduckgo-bangs.nix { }; tic-80 = pkgs.callPackage ./tic-80.nix { }; + sioyek = libsForQt5.callPackage ./sioyek.nix { }; } diff --git a/pkgs/sioyek.nix b/pkgs/sioyek.nix new file mode 100644 index 00000000..60fbe76f --- /dev/null +++ b/pkgs/sioyek.nix @@ -0,0 +1,72 @@ +{ stdenv, lib, fetchFromGitHub, qtbase, qt3d, qmake, wrapQtAppsHook, harfbuzz +, pkgconfig, mupdf, zlib, freetype, libGLU, gumbo, jbig2dec, openjpeg_2 }: + +stdenv.mkDerivation rec { + pname = "sioyek"; + version = "1.0.0"; + + src = fetchFromGitHub { + owner = "ahrm"; + repo = pname; + rev = "v${version}"; + sha256 = "sha256-6eyUwrXeAkWpzwyIhWa/h6YZrSxztWwYBKCSnL2fsjE="; + fetchSubmodules = true; + }; + + nativeBuildInputs = [ qmake wrapQtAppsHook pkgconfig ]; + + buildInputs = [ + qtbase + qt3d + harfbuzz + + # Replacing the application's vendored dependencies with the system + # libraries. + mupdf + zlib + + # Since we're using libraries from the system, we'll also have to + # link several libraries from the application manually. + gumbo + jbig2dec + openjpeg_2 + ]; + + postPatch = '' + substituteInPlace pdf_viewer_build_config.pro \ + --replace "-Lmupdf/build/release -lmupdf -lmupdf-third -lmupdf-threads" "-L${mupdf.dev}/lib -lmupdf -lmupdf-third -lharfbuzz -lfreetype -lgumbo -ljbig2dec -lopenjp2 -ljpeg" \ + --replace 'INCLUDEPATH += ./pdf_viewer\' 'INCLUDEPATH += ./pdf_viewer ${mupdf.dev}/include ${zlib.dev}/include' + + # Remove and replace it with packages from nixpkgs + sed -i -e '4,6d' pdf_viewer_build_config.pro + '' + lib.optionalString stdenv.isLinux '' + substituteInPlace pdf_viewer/main.cpp \ + --replace "/usr/share/sioyek" "$out/share/sioyek" \ + --replace "/etc/sioyek" "$out/etc/sioyek" + ''; + + qmakeFlags = + if stdenv.isLinux then [ "DEFINES+=LINUX_STANDARD_PATHS" ] else [ ]; + + preBuild = '' + # Remove and replace it with packages from nixpkgs. + rm -r mupdf zlib + ''; + + # Taken from `build_linux.sh` script. + postInstall = '' + install -Dm644 tutorial.pdf -t $out/share/sioyek + install -Dm644 pdf_viewer/shaders/* -t $out/share/sioyek/shaders + install -Dm644 pdf_viewer/keys.config -t $out/etc/sioyek + install -Dm644 pdf_viewer/prefs.config -t $out/etc/sioyek + install -Dm644 pdf_viewer/keys_user.config -t $out/share/sioyek + install -Dm644 pdf_viewer/prefs_user.config -t $out/share/sioyek + ''; + + meta = with lib; { + description = + "PDF viewer designed for reading research papers and technical books"; + homepage = "https://sioyek.info"; + license = licenses.gpl3; + }; +}