diff options
Diffstat (limited to 'flake.nix')
-rw-r--r-- | flake.nix | 70 |
1 files changed, 59 insertions, 11 deletions
@@ -1,3 +1,5 @@ | |||
1 | # Build environment and recipe for the Markdown course website example. | ||
2 | # | ||
1 | # Author: Pacien TRAN-GIRARD | 3 | # Author: Pacien TRAN-GIRARD |
2 | # Licence: EUPL-1.2 | 4 | # Licence: EUPL-1.2 |
3 | 5 | ||
@@ -14,19 +16,65 @@ | |||
14 | flake-utils.lib.eachDefaultSystem (system: | 16 | flake-utils.lib.eachDefaultSystem (system: |
15 | with nixpkgs.legacyPackages.${system}; | 17 | with nixpkgs.legacyPackages.${system}; |
16 | let | 18 | let |
19 | texliveDist = texlive.combined.scheme-full; | ||
20 | solutionsSecret = "topsecret"; | ||
17 | 21 | ||
18 | tools = [ | 22 | compileQuarto = options: stdenv.mkDerivation { |
19 | pandoc | 23 | name = "quarto-book"; |
20 | quarto | 24 | src = ./.; |
21 | ]; | 25 | nativeBuildInputs = [ quarto ]; |
26 | buildPhase = '' | ||
27 | export HOME=/build | ||
28 | ${options} quarto render | ||
29 | ''; | ||
30 | installPhase = '' | ||
31 | mkdir -p "$out" | ||
32 | cp -r _book/* "$out/" | ||
33 | ''; | ||
34 | }; | ||
22 | 35 | ||
23 | in lib.fold lib.recursiveUpdate { } [ | 36 | compilePandoc = src: to: options: stdenv.mkDerivation { |
37 | name = "pandoc-output"; | ||
38 | inherit src; | ||
39 | nativeBuildInputs = [ pandoc texliveDist ]; | ||
40 | installPhase = '' | ||
41 | mkdir -p "$out" | ||
42 | for f in *.md; do | ||
43 | ${options} pandoc $f \ | ||
44 | --lua-filter ${./filters/strip-solutions.lua} \ | ||
45 | --output "$out"/$(basename $f .md).pdf \ | ||
46 | --to ${to} | ||
47 | done | ||
48 | ''; | ||
49 | }; | ||
24 | 50 | ||
25 | { | 51 | in { |
26 | devShell = flaky-utils.lib.mkDevShell { | ||
27 | inherit pkgs tools; | ||
28 | }; | ||
29 | } | ||
30 | 52 | ||
31 | ]); | 53 | devShell = flaky-utils.lib.mkDevShell { |
54 | inherit pkgs; | ||
55 | tools = [ quarto pandoc texlive ]; | ||
56 | }; | ||
57 | |||
58 | packages = rec { | ||
59 | website-public = compileQuarto "STRIP_SOLUTIONS=1"; | ||
60 | website-private = compileQuarto ""; | ||
61 | website = runCommand "website-combined" { } '' | ||
62 | mkdir -p "$out" | ||
63 | cp -r "${website-public}"/* "$out/" | ||
64 | mkdir -p "$out/${solutionsSecret}" | ||
65 | cp -r "${website-private}"/* "$out/${solutionsSecret}" | ||
66 | ''; | ||
67 | |||
68 | pdf-slides = compilePandoc ./lectures "beamer" ""; | ||
69 | pdf-exercises = compilePandoc ./exercises "pdf" "STRIP_SOLUTIONS=1"; | ||
70 | pdf-solutions = compilePandoc ./exercises "pdf" ""; | ||
71 | pdf = runCommand "pdf-combined" { } '' | ||
72 | mkdir -p "$out" | ||
73 | ln -s ${pdf-slides} "$out/slides" | ||
74 | ln -s ${pdf-exercises} "$out/exercises" | ||
75 | ln -s ${pdf-solutions} "$out/solutions" | ||
76 | ''; | ||
77 | }; | ||
78 | |||
79 | }); | ||
32 | } | 80 | } |