File tree Expand file tree Collapse file tree 1 file changed +76
-0
lines changed
Expand file tree Collapse file tree 1 file changed +76
-0
lines changed Original file line number Diff line number Diff line change 1+ {
2+ perSystem =
3+ { config
4+ , pkgs
5+ , ...
6+ } : {
7+ packages = {
8+ ui = pkgs . stdenv . mkDerivation {
9+ pname = "leios-ui" ;
10+ version = "0.2.0" ;
11+
12+ src = ./. ;
13+
14+ nativeBuildInputs = with pkgs ; [
15+ nodejs
16+ nodePackages . npm
17+ ] ;
18+
19+ buildPhase = ''
20+ # Install dependencies
21+ npm ci --frozen-lockfile
22+
23+ # Build the application
24+ npm run build
25+ '' ;
26+
27+ installPhase = ''
28+ mkdir -p $out
29+ cp -r dist/* $out/
30+ '' ;
31+ } ;
32+
33+ ui-live = pkgs . writeShellApplication {
34+ name = "ui-live" ;
35+ runtimeInputs = with pkgs ; [
36+ python3
37+ xdg-utils
38+ ] ;
39+ text = ''
40+ UI_PATH="${ config . packages . ui } "
41+ PORT='' ${PORT:-8080}
42+ HOST='' ${HOST:-localhost}
43+
44+ echo "Starting HTTP server for Leios UI at http://$HOST:$PORT"
45+ echo "UI assets served from: $UI_PATH"
46+
47+ # Start the HTTP server in the background
48+ cd "$UI_PATH"
49+ python3 -m http.server "$PORT" --bind "$HOST" &
50+ SERVER_PID=$!
51+
52+ # Wait a moment for server to start
53+ sleep 2
54+
55+ # Open browser with scenario=2
56+ URL="http://$HOST:$PORT/?scenario=2"
57+ echo "Opening browser to: $URL"
58+ xdg-open "$URL" || echo "Could not open browser automatically. Please visit: $URL"
59+
60+ # Function to cleanup on exit
61+ cleanup() {
62+ echo "Stopping server..."
63+ kill $SERVER_PID 2>/dev/null || true
64+ exit 0
65+ }
66+
67+ # Set up signal handlers
68+ trap cleanup SIGINT SIGTERM
69+
70+ echo "Server running. Press Ctrl+C to stop."
71+ wait $SERVER_PID
72+ '' ;
73+ } ;
74+ } ;
75+ } ;
76+ }
You can’t perform that action at this time.
0 commit comments