about summary refs log tree commit diff
path: root/nixpkgs/pkgs/tools/typesetting/sile/default.nix
blob: 966d657ae7d0a1d61a5b5d7a69b635bb58c42f5d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
{ stdenv, darwin, fetchurl, makeWrapper, pkgconfig
, harfbuzz, icu
, fontconfig, lua, libiconv
, makeFontsConf, gentium, gentium-book-basic, dejavu_fonts
}:

with stdenv.lib;

let
  luaEnv = lua.withPackages(ps: with ps;[ lpeg luaexpat lua-zlib luafilesystem luasocket luasec]);

in

stdenv.mkDerivation rec {
  name = "sile-${version}";
  version = "0.9.5.1";

  src = fetchurl {
    url = "https://github.com/simoncozens/sile/releases/download/v${version}/${name}.tar.bz2";
    sha256 = "0fh0jbpsyqyq0hzq4midn7yw2z11hqdgqb9mmgz766cp152wrkb0";
  };

  nativeBuildInputs = [pkgconfig makeWrapper];
  buildInputs = [ harfbuzz icu fontconfig libiconv luaEnv ]
  ++ optional stdenv.isDarwin darwin.apple_sdk.frameworks.AppKit
  ;

  preConfigure = optionalString stdenv.isDarwin ''
    sed -i -e 's|@import AppKit;|#import <AppKit/AppKit.h>|' src/macfonts.m
  '';

  NIX_LDFLAGS = optionalString stdenv.isDarwin "-framework AppKit";

  FONTCONFIG_FILE = makeFontsConf {
    fontDirectories = [
      gentium
      gentium-book-basic
      dejavu_fonts
    ];
  };

  doCheck = stdenv.targetPlatform == stdenv.hostPlatform
  && ! stdenv.isAarch64 # random seg. faults
  && ! stdenv.isDarwin; # dy lib not found

  enableParallelBuilding = true;

  checkPhase = ''
    make documentation/developers.pdf documentation/sile.pdf
  '';

  postInstall = ''
    install -D -t $out/share/doc/sile documentation/*.pdf
  '';

  # Hack to avoid TMPDIR in RPATHs.
  preFixup = ''rm -rf "$(pwd)" && mkdir "$(pwd)" '';

  outputs = [ "out" "doc" ];

  meta = {
    description = "A typesetting system";
    longDescription = ''
      SILE is a typesetting system; its job is to produce beautiful
      printed documents. Conceptually, SILE is similar to TeX—from
      which it borrows some concepts and even syntax and
      algorithms—but the similarities end there. Rather than being a
      derivative of the TeX family SILE is a new typesetting and
      layout engine written from the ground up using modern
      technologies and borrowing some ideas from graphical systems
      such as InDesign.
    '';
    homepage = http://www.sile-typesetter.org;
    platforms = platforms.unix;
    license = licenses.mit;
  };
}