From f0a1b103e0854aa35d257703971092a8810fedd2 Mon Sep 17 00:00:00 2001 From: Sk7Str1p3 Date: Sun, 19 Apr 2026 23:11:06 +0300 Subject: [PATCH] feat(docs): server --- docs/default.nix | 4 +++- docs/docgen.nix | 1 + docs/server.nix | 23 +++++++++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 docs/server.nix diff --git a/docs/default.nix b/docs/default.nix index 6c321c3..68d3713 100644 --- a/docs/default.nix +++ b/docs/default.nix @@ -18,12 +18,14 @@ generator uses orderKey of type "{num}|{mdPath}" and derives indentation from path's depth, so chapters have proper order. - run `nix build .#docBuild` to build documentation + run `nix build .#docBuild` to build documentation. + run `nix run .#docServe` to serve documentation site */ { perSystem = { pkgs, ... }: rec { packages.docBuild = pkgs.callPackage ../docs/docgen.nix { }; + packages.docServe = pkgs.callPackage ../docs/server.nix { doc = packages.docBuild; }; }; } diff --git a/docs/docgen.nix b/docs/docgen.nix index 71f403c..db07044 100644 --- a/docs/docgen.nix +++ b/docs/docgen.nix @@ -17,6 +17,7 @@ stdenvNoCC.mkDerivation { ".*flake\\.nix$" "docs/docgen.nix" + "docs/server.nix" ]; shouldExclude = relPath: lib.any (pattern: builtins.match pattern relPath != null) excluded; diff --git a/docs/server.nix b/docs/server.nix new file mode 100644 index 0000000..bdc3c58 --- /dev/null +++ b/docs/server.nix @@ -0,0 +1,23 @@ +# from `nix-community/stylix` +{ + doc, + http-server, + writeShellApplication, +}: +writeShellApplication { + name = "serve-docs"; + runtimeInputs = [ http-server ]; + runtimeEnv.server_flags = [ + # Search for available port + "--port=0" + + # Disable browser cache + "-c-1" + + # Open using xdg-open + "-o" + ]; + text = '' + http-server ${doc} "''${server_flags[@]}" + ''; +}