File tree Expand file tree Collapse file tree
documentation/docs/integration Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ A complete example looks like this:
3030 packages.default = pkgs.hello;
3131
3232 # (3) point mkdocs-flake to your mkdocs root folder
33- documentation.mkdocs-root = " ./docs" ;
33+ documentation.mkdocs-root = ./docs;
3434
3535 # (4) Build the docs:
3636 # `nix build .#documentation`
Original file line number Diff line number Diff line change 101101 ] ;
102102 } ;
103103
104- documentation . mkdocs-root = " ./documentation" ;
104+ documentation . mkdocs-root = ./documentation ;
105105
106106 packages = {
107107 default = config . packages . mkdocs ;
Original file line number Diff line number Diff line change 44 cfg = config . documentation ;
55
66 strict = lib . optionalString cfg . strict "--strict" ;
7- docsRoot = flakeSelf + "/" + cfg . mkdocs-root ;
87in
98
109{
1110 options . documentation = {
1211 mkdocs-root = lib . mkOption {
13- type = lib . types . nullOr lib . types . str ;
12+ type = lib . types . nullOr lib . types . path ;
1413 default = null ;
1514 example = "./documentation" ;
1615 description = "Path to your mkdocs documentation project with mkdocs.yml. Relative from your flake.nix." ;
3332
3433 config = lib . mkIf ( cfg . mkdocs-root != null ) {
3534 packages . documentation = pkgs . runCommand "mkdocs-flake-documentation" { } ''
36- cd ${ docsRoot }
35+ cd ${ cfg . mkdocs-root }
3736 ${ cfg . mkdocs-package } /bin/mkdocs build ${ strict } --site-dir $out
3837 '' ;
3938
4241 program = pkgs . writeShellScriptBin "mkdocs-watch" ''
4342 set -euo pipefail
4443 if ! test -f mkdocs.yml; then
45- if test -f "${ cfg . mkdocs-root } /mkdocs.yml"; then
46- echo "Your documentation is in ${ cfg . mkdocs-root } . Switching into that folder."
47- cd "${ cfg . mkdocs-root } "
44+ rel_path=${ lib . path . removePrefix ( /. + ( builtins . unsafeDiscardStringContext flakeSelf . outPath ) ) cfg . mkdocs-root }
45+ if test -f "$rel_path/mkdocs.yml"; then
46+ echo "Your documentation is in $rel_path. Switching into that folder."
47+ cd "$rel_path"
4848 else
4949 echo "Can't find mkdocs.yml. Is your flake's `documentation.mkdocs-root` set correctly?"
5050 fi
You can’t perform that action at this time.
0 commit comments