11{
22 lib ,
33 stdenv ,
4- fetchurl ,
4+ fetchzip ,
55
66 # nativeBuildInputs
7- gitMinimal ,
87 pkg-config ,
9- makeWrapper ,
8+ jq ,
9+ cargo ,
10+ rustc ,
11+ rustPlatform ,
1012
1113 # buildInputs
1214 lua ,
1315 harfbuzz ,
1416 icu ,
1517 fontconfig ,
1618 libiconv ,
19+ stylua ,
20+ typos ,
1721 darwin ,
1822 # FONTCONFIG_FILE
1923 makeFontsConf ,
2630
2731stdenv . mkDerivation ( finalAttrs : {
2832 pname = "sile" ;
29- version = "0.14.17 " ;
33+ version = "0.15.5 " ;
3034
31- src = fetchurl {
32- url = "https://github.com/sile-typesetter/sile/releases/download/v${ finalAttrs . version } /sile-${ finalAttrs . version } .tar.xz " ;
33- sha256 = "sha256-f4m+3s7au1FoJQrZ3YDAntKJyOiMPQ11bS0dku4GXgQ =" ;
35+ src = fetchzip {
36+ url = "https://github.com/sile-typesetter/sile/releases/download/v${ finalAttrs . version } /sile-${ finalAttrs . version } .zip " ;
37+ sha256 = "sha256-zP+MGCXGEg19U6tMrHIdgAAfKQT21vFtmoEROXgxUB0 =" ;
3438 } ;
3539
36- configureFlags = [
37- "--with-system-luarocks"
38- "--with-manual"
39- ] ;
40+ cargoDeps = rustPlatform . fetchCargoTarball {
41+ inherit ( finalAttrs ) src ;
42+ dontConfigure = true ;
43+ hash = "sha256-hmgDG29C5JfQX2acMr8c3lmswa1u5XHauRWFd4QGmOo=" ;
44+ } ;
4045
4146 nativeBuildInputs = [
42- gitMinimal
4347 pkg-config
44- makeWrapper
48+ jq
49+ cargo
50+ rustc
51+ rustPlatform . cargoSetupHook
4552 ] ;
53+
4654 buildInputs =
4755 [
4856 finalAttrs . finalPackage . passthru . luaEnv
4957 harfbuzz
5058 icu
5159 fontconfig
5260 libiconv
61+ stylua
62+ typos
5363 ]
5464 ++ lib . optionals stdenv . hostPlatform . isDarwin [
5565 darwin . apple_sdk . frameworks . AppKit
5666 ] ;
67+
68+ configureFlags =
69+ [
70+ # Nix will supply all the Lua dependencies, so stop the build system from
71+ # bundling vendored copies of them.
72+ "--with-system-lua-sources"
73+ "--with-system-luarocks"
74+ # The automake check target uses pdfinfo to confirm the output of a test
75+ # run, and uses autotools to discover it. This flake build eschews that
76+ # test because it is run from the source directory but the binary is
77+ # already built with system paths, so it can't be checked under Nix until
78+ # after install. After install the Makefile isn't available of course, so
79+ # we have our own copy of it with a hard coded path to `pdfinfo`. By
80+ # specifying some binary here we skip the configure time test for
81+ # `pdfinfo`, by using `false` we make sure that if it is expected during
82+ # build time we would fail to build since we only provide it at test time.
83+ "PDFINFO=false"
84+ ]
85+ ++ lib . optionals ( ! lua . pkgs . isLuaJIT ) [
86+ "--without-luajit"
87+ ] ;
88+
89+ outputs = [
90+ "out"
91+ "doc"
92+ "man"
93+ "dev"
94+ ] ;
95+
96+ # TODO: At some point, upstream should support installing the pre-built
97+ # manual automatically
98+ postInstall = ''
99+ install -Dm0644 documentation/sile.pdf $out/share/doc/sile/manual.pdf
100+ '' ;
101+
102+ FONTCONFIG_FILE = makeFontsConf {
103+ fontDirectories = [
104+ gentium
105+ ] ;
106+ } ;
107+
108+ enableParallelBuilding = true ;
109+
57110 passthru = {
58111 luaEnv = lua . withPackages (
59112 ps :
60113 with ps ;
61114 [
62115 cassowary
63116 cldr
64- cosmo
65117 fluent
66118 linenoise
67119 loadkit
@@ -77,6 +129,12 @@ stdenv.mkDerivation (finalAttrs: {
77129 luautf8
78130 penlight
79131 vstruct
132+ # lua packages needed for testing
133+ busted
134+ luacheck
135+ # packages needed for building api docs
136+ ldoc
137+ # NOTE: Add lua packages here, to change the luaEnv also read by `flake.nix`
80138 ]
81139 ++ lib . optionals ( lib . versionOlder lua . luaversion "5.2" ) [
82140 bit32
@@ -85,9 +143,10 @@ stdenv.mkDerivation (finalAttrs: {
85143 compat53
86144 ]
87145 ) ;
146+
88147 # Copied from Makefile.am
89148 tests . test = lib . optionalAttrs ( ! ( stdenv . hostPlatform . isDarwin && stdenv . hostPlatform . isAarch64 ) ) (
90- runCommand "sile -test"
149+ runCommand "${ finalAttrs . pname } -test"
91150 {
92151 nativeBuildInputs = [
93152 poppler_utils
@@ -103,45 +162,6 @@ stdenv.mkDerivation (finalAttrs: {
103162 ) ;
104163 } ;
105164
106- postPatch =
107- ''
108- patchShebangs build-aux/*.sh
109- ''
110- + lib . optionalString stdenv . hostPlatform . isDarwin ''
111- sed -i -e 's|@import AppKit;|#import <AppKit/AppKit.h>|' src/macfonts.m
112- '' ;
113-
114- NIX_LDFLAGS = lib . optionalString stdenv . hostPlatform . isDarwin "-framework AppKit" ;
115-
116- FONTCONFIG_FILE = makeFontsConf {
117- fontDirectories = [
118- gentium
119- ] ;
120- } ;
121-
122- enableParallelBuilding = true ;
123-
124- preBuild = lib . optionalString stdenv . cc . isClang ''
125- substituteInPlace libtexpdf/dpxutil.c \
126- --replace "ASSERT(ht && ht->table && iter);" "ASSERT(ht && iter);"
127- '' ;
128-
129- # remove forbidden references to $TMPDIR
130- preFixup = lib . optionalString stdenv . hostPlatform . isLinux ''
131- for f in "$out"/bin/*; do
132- if isELF "$f"; then
133- patchelf --shrink-rpath --allowed-rpath-prefixes "$NIX_STORE" "$f"
134- fi
135- done
136- '' ;
137-
138- outputs = [
139- "out"
140- "doc"
141- "man"
142- "dev"
143- ] ;
144-
145165 meta = {
146166 description = "Typesetting system" ;
147167 longDescription = ''
0 commit comments