Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP use mermaid? #407

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions site/book.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ no-section-label = true

[output.html.print]
enable = false # big single page; don't need that
additional-js = ["mermaid.min.js", "mermaid-init.js"]

[output.linkcheck]
follow-web-links = false # no Internet during the build

[preprocessor.mermaid]
command = "mdbook-mermaid"
1 change: 1 addition & 0 deletions site/mermaid-init.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mermaid.initialize({startOnLoad:true});
1,282 changes: 1,282 additions & 0 deletions site/mermaid.min.js

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion site/site-module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@
packages = {
default = pkgs.stdenvNoCC.mkDerivation {
name = "site";
nativeBuildInputs = [ pkgs.mdbook pkgs.mdbook-linkcheck ];
nativeBuildInputs = [
pkgs.mdbook
pkgs.mdbook-linkcheck
pkgs.mdbook-mermaid
];
src = ./.;
buildPhase = ''
runHook preBuild
Expand Down
39 changes: 13 additions & 26 deletions site/src/dogfood-a-reusable-module.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,25 @@ You can distribute reusable module logic through flakes using flake attributes,
However, importing from `self` is not possible, because such an import could affect the `self` attribute set.
To use your own exported module, you have to reference it directly.

```
┌─────────┐ ┌───────────────────────────────────┐
│ imports │ │ config.flake.flakeModules.default │
└─────┬───┘ └─────────────────┬─────────────────┘
│ │
│ ┌──────────────────┘
│ │
┌─────▼──────▼─────┐
│ flake-module.nix │
└──────────────────┘
```mermaid
flowchart TD;

imports --> flake-module.nix;
config.flake.flakeModules.default --> flake-module.nix;
```

If your module does not need anything from the local flake's lexical scope, you might implement the references in the diagram above.
But if you do need to reference, say, a package from your local flake, then you need to apply one of the solutions from [Define a Module in a Separate File](define-module-in-separate-file.md).
Instead of the arrows joining at the file name, we'll need a `let` binding.

```
┌─────────┐ ┌───────────────────────────────────┐
│ imports │ │ config.flake.flakeModules.default │
└─────┬───┘ └─────────────────┬─────────────────┘
│ │
│ ┌─────────────────┘
│ │
┌─────▼───────▼─────────┐
│ let flakeModule = ... │
└─────────┬─────────────┘
┌─────────▼────────┐
│ flake-module.nix │
└──────────────────┘
```mermaid
flowchart TD;

imports --> flakeModule;
flakeModule ["let flakeModule = ..."];
config.flake.flakeModules.default --> flakeModule;
flakeModule -> flake-module.nix;

```

## Example with `importApply`
Expand Down