diff --git a/flake-modules/dev/devshell.nix b/flake-modules/dev/devshell.nix index 7eb39caf..e0a07bfc 100644 --- a/flake-modules/dev/devshell.nix +++ b/flake-modules/dev/devshell.nix @@ -81,10 +81,9 @@ echo -e "\n=> Documentation successfully built ('$doc_derivation')" - port=8000 - echo -e "\n=> Now open your browser and navigate to 'localhost:$port'\n" + echo -e "\n=> You can then open your browser to view the doc\n" - ${pkgs.lib.getExe pkgs.python3} -m http.server -d "$doc_derivation"/share/doc + (cd "$doc_derivation"/share/doc && ${pkgs.lib.getExe pkgs.python3} ${./server.py}) ''; } { diff --git a/flake-modules/dev/server.py b/flake-modules/dev/server.py new file mode 100644 index 00000000..5928fafe --- /dev/null +++ b/flake-modules/dev/server.py @@ -0,0 +1,16 @@ +import http.server + +PORT = 8000 + + +class UncachedHTTPHandler(http.server.SimpleHTTPRequestHandler): + def end_headers(self): + self.send_header("Cache-Control", "no-cache, no-store, must-revalidate") + self.send_header("Pragma", "no-cache") + self.send_header("Expires", "0") + super().end_headers() + + +with http.server.HTTPServer(("", PORT), UncachedHTTPHandler) as httpd: + print(f"Serving documentation at http://localhost:{PORT}") + httpd.serve_forever()