-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
152 lines (123 loc) · 4.49 KB
/
flake.nix
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
{
description = "European Commission theme with LaTeX/Pandoc";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
theme-ec.url = "git+https://code.europa.eu/pol/european-commission-latex-beamer-theme/";
ec-fonts.url = "git+https://code.europa.eu/pol/ec-fonts/";
ci-detector.url = "github:loophp/ci-detector";
};
outputs = inputs @ {flake-parts, ...}:
flake-parts.lib.mkFlake {inherit inputs;} {
systems = inputs.nixpkgs.lib.systems.flakeExposed;
perSystem = {
config,
self',
inputs',
pkgs,
system,
...
}: let
pkgs = import inputs.nixpkgs {
overlays =
[
inputs.theme-ec.overlays.default
]
++ inputs.nixpkgs.lib.optional (inputs.ci-detector.lib.notInCI) inputs.ec-fonts.overlays.default;
inherit system;
};
tex = pkgs.texlive.combine {
inherit (pkgs.texlive) scheme-full latex-bin latexmk;
latex-theme-ec = {
pkgs = [pkgs.latex-theme-ec] ++ inputs.nixpkgs.lib.optional (inputs.ci-detector.lib.notInCI) pkgs.ec-square-sans-lualatex;
};
};
pandoc = pkgs.writeShellApplication {
name = "pandoc";
text = ''
${pkgs.pandoc}/bin/pandoc \
--data-dir ${pkgs.pandoc-template-ec} \
"$@"
'';
runtimeInputs = [tex];
};
myaspell = pkgs.aspellWithDicts (d: [d.en d.en-science d.en-computers d.fr d.be]);
pandoc-presentation-app = pkgs.writeShellApplication {
name = "pandoc-presentation-app";
text = ''
export LC_ALL="C"
export TEXINPUTS="${./.}//:"
${pkgs.pandoc}/bin/pandoc \
--standalone \
--pdf-engine=lualatex \
--to=beamer \
--template=${pkgs.pandoc-template-ec}/templates/beamer-theme-ec.latex \
--slide-level=2 \
--shift-heading-level=0 \
"$@"
'';
runtimeInputs = [tex];
};
pandoc-presentation = pkgs.stdenvNoCC.mkDerivation {
name = "ec-latex-beamer-theme--pandoc-presentation";
src = pkgs.lib.cleanSource ./.;
buildInputs = [tex];
# TMPDIR is provided by latexmk, and lualatex needs HOME to be set
# for temporary files while building
HOME = "$TMPDIR";
TEXINPUTS = "${./.}//:";
LC_ALL = "C";
buildPhase = ''
runHook preBuild
${pandoc-presentation-app}/bin/pandoc-presentation-app \
--from=markdown \
--output=pandoc-presentation.pdf \
$src/src/pandoc/presentation/*.md
runHook postBuild
'';
installPhase = ''
runHook preInstall
install -m644 -D *.pdf --target $out/
runHook postInstall
'';
};
watch-pandoc-presentation-app = pkgs.writeShellApplication {
name = "watch-pandoc-presentation";
text = ''
echo "Now watching files for changes..."
while true; do \
${pandoc-presentation-app}/bin/pandoc-presentation-app "$@"
${pkgs.inotify-tools}/bin/inotifywait --exclude '\.pdf|\.git' -qre close_write .; \
done
'';
runtimeInputs = [tex];
};
in {
# nix fmt
formatter = pkgs.alejandra;
# nix run git+https://code.europa.eu/pol/european-commission-latex-beamer-theme/#pandoc-presentation -- --output=output.pdf --from=markdown /path/to/the/file.md
apps.pandoc-presentation = {
type = "app";
program = pandoc-presentation-app;
};
# nix run git+https://code.europa.eu/pol/european-commission-latex-beamer-theme/#watch-pandoc-presentation -- --output=output.pdf --from=markdown /path/to/file.md
apps.watch-pandoc-presentation = {
type = "app";
program = watch-pandoc-presentation-app;
};
# nix build .#pandoc-presentation
packages.default = pandoc-presentation;
# nix develop
devShells.default = pkgs.mkShellNoCC {
name = "ec-latex-beamer-theme--devshell";
buildInputs = [
tex
pandoc
pkgs.nodePackages.cspell
pkgs.nodePackages.prettier
myaspell
];
};
checks.pandoc-presentation = pandoc-presentation;
};
};
}