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

Merge pull request #811 from fricklerhandwerk/simplify-devmode

fix and simplify devmode script
This commit is contained in:
Silvan Mosberger 2023-11-30 16:55:13 +01:00 committed by GitHub
commit 0249563433
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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 {