blob: c385bea1b7ca42449a5a79b4360123e8a0526478 (
plain)
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
{ lib, flake-parts-lib, ... }:
let
inherit (lib)
mkIf
mkOption
mkEnableOption
types
;
inherit (flake-parts-lib) mkPerSystemOption;
in
{
options.perSystem = mkPerSystemOption (
{ config, pkgs, ... }:
{
options = {
texShell = {
scheme = mkOption {
type = types.packages;
default = pkgs.texliveSmall;
description = ''
The base texlive scheme to use. Choose between:
- pkgs.texliveSmall
- pkgs.texliveMedium
- pkgs.texliveFull
- pkgs.texliveBasic
- pkgs.texliveMinimal
- pkgs.texliveTeTex
'';
};
extraPackages = mkOption {
type = types.functionTo (types.listOf types.package);
description = ''
Extra packages to add to the texlive scheme.
Unlike more sophisticated projects such as [latex-utils](https://github.com/jmmaloney4/latex-utils), there is no auto-discovery of necessary packages.
'';
default = _: [ ];
};
latexmk = {
enable = mkEnableOption "latexmk";
rc = mkOption {
type = types.lines;
description = "contents of the .latexmkrc file";
default = /* perl */ ''
$out_dir = '.latex-build';
$pdf_mode = 1;
$pdflatex = 'lualatex -interaction=nonstopmode -file-line-error -synctex=1 %O %S';
'';
};
rcFile = mkOption {
type = types.path;
default = pkgs.writeText "latexmkrc" config.texShell.latexmk.rc;
description = "the .latexmkrc file";
};
_wrapper = mkOption {
type = types.functionTo types.package;
readOnly = true;
internal = true;
description = "A wrapper derivation to add the rc file to latexmk";
default =
tex:
pkgs.symlinkJoin {
inherit (tex) name;
nativeBuildInputs = [ pkgs.makeWrapper ];
paths = [ tex ];
postBuild = ''
wrapProgram $out/bin/latexmk --add-flags "-r" --add-flags "${config.texShell.latexmk.rcFile}"
'';
};
};
};
build = {
package = mkOption {
type = types.package;
readOnly = true;
description = "The final texlive package";
default =
let
wrapper = if config.texShell.latexmk.enable then config.texShell.latexmk._wrapper else x: x;
in
wrapper (config.texShell.scheme.withPackages config.texShell.extraPackages);
};
devShell = mkOption {
type = types.package;
readOnly = true;
description = "The final texlive shell";
default = pkgs.mkShellNoCC { buildInputs = [ config.texShell.build.package ]; };
};
};
};
};
config = {
texShell.extraPackages = mkIf config.texShell.latexmk.enable (ps: [ ps.latexmk ]);
};
}
);
}
|