mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-22 05:33:23 +00:00
4a7f99d55d
Part of: https://github.com/NixOS/nixpkgs/issues/108938 meta = with stdenv.lib; is a widely used pattern. We want to slowly remove the `stdenv.lib` indirection and encourage people to use `lib` directly. Thus let’s start with the meta field. This used a rewriting script to mostly automatically replace all occurances of this pattern, and add the `lib` argument to the package header if it doesn’t exist yet. The script in its current form is available at https://cs.tvl.fyi/depot@2f807d7f141068d2d60676a89213eaa5353ca6e0/-/blob/users/Profpatsch/nixpkgs-rewriter/default.nix
74 lines
2.0 KiB
Nix
74 lines
2.0 KiB
Nix
{ lib, stdenv, fetchFromGitHub
|
||
, freetype, harfbuzz, jbig2dec, libjpeg, libX11, mupdf_1_17, ncurses, openjpeg
|
||
, openssl
|
||
|
||
, imageSupport ? true, imlib2 ? null }:
|
||
|
||
let
|
||
package = if imageSupport
|
||
then "jfbview"
|
||
else "jfbpdf";
|
||
binaries = if imageSupport
|
||
then [ "jfbview" "jpdfcat" "jpdfgrep" ] # all require imlib2
|
||
else [ "jfbpdf" ]; # does not
|
||
in
|
||
|
||
stdenv.mkDerivation rec {
|
||
name = "${package}-${version}";
|
||
version = "0.5.7";
|
||
|
||
src = fetchFromGitHub {
|
||
repo = "JFBView";
|
||
owner = "jichu4n";
|
||
rev = version;
|
||
sha256 = "0ppns49hnmp04zdjw6wc28v0yvz31rkzvd5ylcj7arikx20llpxf";
|
||
};
|
||
|
||
postPatch = ''
|
||
substituteInPlace main.cpp \
|
||
--replace "<stropts.h>" "<sys/ioctl.h>"
|
||
'';
|
||
|
||
hardeningDisable = [ "format" ];
|
||
|
||
buildInputs = [
|
||
freetype harfbuzz jbig2dec libjpeg libX11 mupdf_1_17 ncurses openjpeg
|
||
openssl
|
||
] ++ stdenv.lib.optionals imageSupport [
|
||
imlib2
|
||
];
|
||
|
||
configurePhase = ''
|
||
# Hack. Probing (`ldconfig -p`) fails with ‘cannot execute binary file’.
|
||
# Overriding `OPENJP2 =` later works, but makes build output misleading:
|
||
substituteInPlace Makefile --replace "ldconfig -p" "echo libopenjp2"
|
||
|
||
make config.mk
|
||
'';
|
||
|
||
buildFlags = binaries;
|
||
enableParallelBuilding = true;
|
||
|
||
installPhase = ''
|
||
mkdir -p $out/bin
|
||
install ${toString binaries} $out/bin
|
||
'';
|
||
|
||
meta = with lib; {
|
||
description = "PDF and image viewer for the Linux framebuffer";
|
||
longDescription = ''
|
||
A very fast PDF and image viewer for the Linux framebuffer with some
|
||
advanced and unique features, including:
|
||
- Reads PDFs (MuPDF) and common image formats (Imlib2)
|
||
- Supports arbitrary zoom (10% - 1000%) and rotation
|
||
- Table of Contents (TOC) viewer for PDF documents
|
||
- Multi-threaded rendering on multi-core machines
|
||
- Asynchronous background rendering of the next page
|
||
- Customizable multi-threaded caching
|
||
'';
|
||
homepage = "https://seasonofcode.com/pages/jfbview.html";
|
||
license = licenses.asl20;
|
||
platforms = platforms.linux;
|
||
};
|
||
}
|