Skip to content

Commit 3ddcd50

Browse files
ureuse devmode utility from nixos/nixpkgs manuals (#788)
Co-authored-by: Valentin Gagarin <[email protected]>
1 parent 801d362 commit 3ddcd50

File tree

1 file changed

+4
-42
lines changed

1 file changed

+4
-42
lines changed

default.nix

Lines changed: 4 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -74,48 +74,10 @@ let
7474
'';
7575
};
7676

77-
devmode =
78-
let
79-
pythonEnvironment = pkgs.python310.withPackages (ps: with ps; [
80-
livereload
81-
]);
82-
script = ''
83-
from livereload import Server
84-
from subprocess import Popen, PIPE
85-
import shlex
86-
import sys
87-
88-
server = Server()
89-
90-
def nix_build():
91-
p = Popen(
92-
shlex.split("nix-build -A build") + sys.argv[1:],
93-
# capture output as text
94-
stdout=PIPE,
95-
stderr=PIPE,
96-
text=True,
97-
)
98-
# we only care about failures
99-
stdout, stderr = p.communicate()
100-
if p.returncode:
101-
print(stderr)
102-
return p
103-
104-
# (re-)build once before serving
105-
nix_build().wait()
106-
107-
server.watch("source/*", nix_build)
108-
server.watch("source/**/*", nix_build)
109-
server.serve(root="result")
110-
'';
111-
in
112-
pkgs.writeShellApplication {
113-
name = "devmode";
114-
runtimeInputs = [ pythonEnvironment ];
115-
text = ''
116-
python ${pkgs.writeText "live.py" script}
117-
'';
118-
};
77+
devmode = pkgs-unstable.devmode.override {
78+
buildArgs = ''-A build --show-trace'';
79+
open = "/index.html";
80+
};
11981
update-nix-releases = pkgs-unstable.callPackage ./nix/update-nix-releases.nix { };
12082
update-nixpkgs-releases = pkgs-unstable.callPackage ./nix/update-nixpkgs-releases.nix { };
12183
in

0 commit comments

Comments
 (0)