Skip to content

Commit

Permalink
feat: add graphviz support
Browse files Browse the repository at this point in the history
  • Loading branch information
codgician committed May 16, 2024
1 parent beef6fc commit ec4d515
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
concatAttrs = attrList: builtins.foldl' (x: y: x // y) { } attrList;
in
concatAttrs [
(import ./revealjs.nix)
(import ./reveal-js.nix)
(import ./filesystem.nix { inherit lib; })
(import ./misc.nix { inherit lib; })
(import ./site.nix)
Expand Down
14 changes: 10 additions & 4 deletions lib/revealjs.nix → lib/reveal-js.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@
pname = name;
inherit version src;

buildInputs = with pkgs; [ pandoc graphviz ];
installPhase =
let
mdPath = "${src}/slides.md";
args = builtins.concatStringsSep " " ([
luaFiltersPath = "${pkgs.pandoc-lua-filters}/share/pandoc/filters";
pandocArgs = builtins.concatStringsSep " " ([
# Use reveal.js from input
"--variable"
"revealjs-url=./assets/reveal.js"
Expand All @@ -33,15 +34,20 @@
# Code highlight theme
"--highlight-style=zenburn"

# Set slide level
"--slide-level ${builtins.toString slideLevel}"

# Add Lua filters
"--lua-filter"
"${luaFiltersPath}/diagram-generator.lua"
] ++ builtins.attrValues (builtins.mapAttrs (k: v: "-V ${k}=${builtins.toString v}") pandocVariables));
in
''
mkdir -p $out/assets
ln -s ${reveal-js} $out/assets/reveal.js
ln -s ${pkgs.nodePackages.katex}/lib/node_modules/katex/dist $out/assets/katex-dist
${pkgs.pandoc}/bin/pandoc -s -t revealjs -o $out/index.html ${mdPath} ${args}
'' + builtins.concatStringsSep "\n" (builtins.map (folder: "ln -s ${folder} $out/${builtins.baseNameOf folder}") additonalFolders);
${pkgs.pandoc}/bin/pandoc --embed-resources -s -t revealjs -o $out/index.html slides.md ${pandocArgs}
'' + builtins.concatStringsSep "\n" (builtins.map (dir: "ln -s ${dir} $out/${builtins.baseNameOf dir}") additonalFolders);

meta = {
inherit license;
Expand Down
25 changes: 25 additions & 0 deletions slides/nix-intro/slides.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,31 @@ subtitle: Declarative builds and deployments
date: 2024.05.20
---

# Test GraphViz

```{ .graphviz caption="This is an image, created by **Graphviz**'s dot." }
digraph finite_state_machine {
rankdir=LR;
size="8,5"
node [shape = doublecircle]; LR_0 LR_3 LR_4 LR_8;
node [shape = circle];
LR_0 -> LR_2 [ label = "SS(B)" ];
LR_0 -> LR_1 [ label = "SS(S)" ];
LR_1 -> LR_3 [ label = "S($end)" ];
LR_2 -> LR_6 [ label = "SS(b)" ];
LR_2 -> LR_5 [ label = "SS(a)" ];
LR_2 -> LR_4 [ label = "S(A)" ];
LR_5 -> LR_7 [ label = "S(b)" ];
LR_5 -> LR_5 [ label = "S(a)" ];
LR_6 -> LR_6 [ label = "S(b)" ];
LR_6 -> LR_5 [ label = "S(a)" ];
LR_7 -> LR_8 [ label = "S(b)" ];
LR_7 -> LR_5 [ label = "S(a)" ];
LR_8 -> LR_6 [ label = "S(b)" ];
LR_8 -> LR_5 [ label = "S(a)" ];
}
```

# Software deployment

::: { .incremental }
Expand Down

0 comments on commit ec4d515

Please sign in to comment.