files.mdbook

Helps with mdbook creation https://rust-lang.github.io/mdBook/

by default it creates gh-pages/mdbook.toml and gh-pages/src/SUMMARY.md

It also create publish-as-gh-pages helper

Full configuration example
#examples/book.nix

{lib, ...}:
let
  project   = "devshell-files";
  author    = "cruel-intentions";
  org-url   = "https://github.com/${author}";
  edit-path = "${org-url}/${project}/edit/master/examples/{path}";
in
{
  files.mdbook.authors      = ["Cruel Intentions <${org-url}>"];
  files.mdbook.enable       = true;
  files.mdbook.gh-author    = author;
  files.mdbook.gh-project   = project;
  files.mdbook.language     = "en";
  files.mdbook.multilingual = false;
  files.mdbook.summary      = builtins.readFile ./summary.md;
  files.mdbook.title        = "Nix DevShell Files Maker";
  files.mdbook.output.html.edit-url-template   = edit-path;
  files.mdbook.output.html.fold.enable         = true;
  files.mdbook.output.html.git-repository-url  = "${org-url}/${project}/tree/master";
  files.mdbook.output.html.no-section-label    = true;
  files.mdbook.output.html.site-url            = "/${project}/";
  files.gitignore.pattern.gh-pages             = true;
  files.text."/gh-pages/src/introduction.md" = builtins.readFile ./readme/about.md;
  files.text."/gh-pages/src/installation.md" = builtins.readFile ./readme/installation.md;
  files.text."/gh-pages/src/examples.md"     = builtins.import   ./readme/examples.nix;
  files.text."/gh-pages/src/modules.md"      = "## Writing new modules";
  files.text."/gh-pages/src/nix-lang.md"     = builtins.readFile ./readme/modules/nix-lang.md;
  files.text."/gh-pages/src/json-nix.md"     = builtins.import   ./readme/modules/json-vs-nix.nix lib;
  files.text."/gh-pages/src/module-spec.md"  = builtins.readFile ./readme/modules/modules.md;
  files.text."/gh-pages/src/share.md"        = builtins.readFile ./readme/modules/share.md;
  files.text."/gh-pages/src/document.md"     = builtins.import   ./readme/modules/document.nix;
  files.text."/gh-pages/src/builtins.md"     = builtins.readFile ./readme/modules/builtins.md;
  files.text."/gh-pages/src/todo.md"         = builtins.readFile ./readme/todo.md;
  files.text."/gh-pages/src/issues.md"       = builtins.readFile ./readme/issues.md;
  files.text."/gh-pages/src/seeAlso.md"      = builtins.readFile ./readme/seeAlso.md;
  files.alias.publish-as-gh-pages-from-local = ''
    # same as publish-as-gh-pages but works local
    cd $PRJ_ROOT
    ORIGIN=`git remote get-url origin`
    cd gh-pages
    mdbook build
    cd book
    git init .
    git add .
    git checkout -b gh-pages
    git commit -m "docs(gh-pages): update gh-pages" .
    git remote add origin $ORIGIN
    git push -u origin gh-pages --force
  '';  
}

type

submodule

default

{
  files.mdbook = { };
}

files.mdbook.enable

Whether to enable mdbook module.

type

boolean

example

{
  files.mdbook.enable = true;
}

default

{
  files.mdbook.enable = false;
}

files.mdbook.authors

Book author

type

null or (non-empty (list of string))

example

{
  files.mdbook.authors = [
    "Cruel Intentions"
  ];
}

default

{
  files.mdbook.authors = null;
}

files.mdbook.build

mdbook output options

type

JSON value

example

{
  files.mdbook.build = {
    build-dir = "book";
  };
}

default

{
  files.mdbook.build = { };
}

files.mdbook.description

Desciption of this book

type

null or string

example

{
  files.mdbook.description = "Modules Docummentation";
}

default

{
  files.mdbook.description = null;
}

files.mdbook.gh-author

Github Owner

type

null or string

example

{
  files.mdbook.gh-author = "cruel-intentions";
}

default

{
  files.mdbook.gh-author = null;
}

files.mdbook.gh-project

Github project

type

null or string

example

{
  files.mdbook.gh-project = "devshell-files";
}

default

{
  files.mdbook.gh-project = null;
}

files.mdbook.language

Book language

type

null or non-empty string

example

{
  files.mdbook.language = "en";
}

default

{
  files.mdbook.language = null;
}

files.mdbook.multilingual

If book has multilingual support

type

boolean

example

{
  files.mdbook.multilingual = true;
}

default

{
  files.mdbook.multilingual = false;
}

files.mdbook.output

mdbook output options

type

JSON value

example

{
  files.mdbook.output = {
    html = {
      fold = {
        enable = true;
      };
    };
  };
}

default

{
  files.mdbook.output = { };
}

files.mdbook.preprocessor

mdbook preprocessor options

type

JSON value

example

{
  files.mdbook.preprocessor = {
    mathjax = {
      renderers = [
        "html"
      ];
    };
  };
}

default

{
  files.mdbook.preprocessor = { };
}

files.mdbook.root-dir

root path of book

type

non-empty string

example

{
  files.mdbook.root-dir = "/gh-pages";
}

default

{
  files.mdbook.root-dir = "/gh-pages";
}

files.mdbook.rust

mdbook rust options

type

JSON value

example

{
  files.mdbook.rust = {
    edition = "2018";
  };
}

default

{
  files.mdbook.rust = { };
}

files.mdbook.summary

Summary of our mkdbook

type

strings concatenated with "\n"

example

{
  files.mdbook.summary = ''
    # SUMMARY
    - [Intro](./intro.md)
  '';
}

default

{
  files.mdbook.summary = ''
    # SUMMARY
  '';
}

files.mdbook.title

Book title

type

null or string

example

{
  files.mdbook.title = "Devshell Files Modules";
}

default

{
  files.mdbook.title = null;
}

files.mdbook.use-default-preprocessor

Disable the default preprocessors

type

boolean

example

{
  files.mdbook.use-default-preprocessor = false;
}

default

{
  files.mdbook.use-default-preprocessor = true;
}