1
0
Fork 0
mirror of https://github.com/NixOS/nix.dev.git synced 2024-10-18 00:06:26 -04:00

fix and simplify devmode script

previously, stderr was garbled, which made it really annoying to deal
with build errors.

it turns out that the library wrapper around calling a process is not
just counterproductive, but also completely unnecessary.

the build now takes longer because it's not incremental any more.
but the problem with `sphinx-build` in a shell environment is that it
doesn't keep track of an entire class of files, that would have to be
considered manually. this is too much manual overhead that doesn't scale
at all. with the new setup the live preview will do exactly what the
final deployment does.

[1]: https://github.com/executablebooks/sphinx-autobuild#relevant-sphinx-bugs

Co-authored-by: Alex Groleau source@proof.construction
This commit is contained in:
Valentin Gagarin 2023-11-13 17:30:54 +01:00
parent a15d8a3eda
commit 63d783a3bc

View file

@ -1,6 +1,6 @@
{
inputs ? import ./nix/sources.nix,
system ? builtins.currentSystem,
{ inputs ? import ./nix/sources.nix
, system ? builtins.currentSystem
,
}:
let
pkgs = import inputs.nixpkgs {
@ -37,19 +37,32 @@ let
livereload
]);
script = ''
from livereload import Server, shell
from livereload import Server
from subprocess import Popen, PIPE
import shlex
server = Server()
build_docs = shell("make html")
def nix_build():
p = Popen(
shlex.split("nix-build -A build"),
# capture output as text
stdout=PIPE,
stderr=PIPE,
text=True,
)
# we only care about failures
stdout, stderr = p.communicate()
if p.returncode:
print(stderr)
return p
print("Doing an initial build of the docs...")
build_docs()
# (re-)build once before serving
nix_build().wait()
server.watch("source/*", build_docs)
server.watch("source/**/*", build_docs)
server.watch("_templates/*.html", build_docs)
server.serve(root="build/html")
server.watch("source/*", nix_build)
server.watch("source/**/*", nix_build)
server.serve(root="result")
'';
in
pkgs.writeShellApplication {