fix part 2
This commit is contained in:
76
flake.nix
76
flake.nix
@@ -31,7 +31,8 @@
|
||||
alembic
|
||||
pydantic
|
||||
pydantic-settings # Settings management
|
||||
psycopg2 # PostgreSQL driver
|
||||
psycopg2 # PostgreSQL driver (sync)
|
||||
asyncpg # PostgreSQL driver (async)
|
||||
# Auth & Security
|
||||
python-jose
|
||||
passlib
|
||||
@@ -88,6 +89,7 @@
|
||||
# Development tools
|
||||
git
|
||||
direnv
|
||||
tmux
|
||||
];
|
||||
|
||||
shellHook = ''
|
||||
@@ -105,6 +107,7 @@
|
||||
echo " Status: ./scripts/dev-services.sh status"
|
||||
echo ""
|
||||
echo "📚 Quick Commands:"
|
||||
echo " Dev (tmux): nix run .#dev"
|
||||
echo " Backend: cd backend && uvicorn app.main:app --reload"
|
||||
echo " Frontend: cd frontend && npm run dev"
|
||||
echo " Database: psql -h localhost -U webref webref"
|
||||
@@ -131,6 +134,7 @@
|
||||
type = "app";
|
||||
program = "${pkgs.writeShellScript "help" ''
|
||||
echo "Available commands:"
|
||||
echo " nix run .#dev - Start backend + frontend in tmux"
|
||||
echo " nix run .#lint - Run all linting checks"
|
||||
echo " nix run .#lint-backend - Run backend linting only"
|
||||
echo " nix run .#lint-frontend - Run frontend linting only"
|
||||
@@ -138,6 +142,76 @@
|
||||
''}";
|
||||
};
|
||||
|
||||
# Development runner with tmux
|
||||
dev = {
|
||||
type = "app";
|
||||
program = "${pkgs.writeShellScript "dev-tmux" ''
|
||||
set -e
|
||||
|
||||
# Check if we're in the project root
|
||||
if [ ! -d "backend" ] || [ ! -d "frontend" ]; then
|
||||
echo "❌ Error: Not in project root directory"
|
||||
echo "Please run this command from the webref project root"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if frontend dependencies are installed
|
||||
if [ ! -d "frontend/node_modules" ]; then
|
||||
echo "📦 Installing frontend dependencies..."
|
||||
cd frontend
|
||||
${pkgs.nodejs}/bin/npm install
|
||||
cd ..
|
||||
fi
|
||||
|
||||
# Set environment variables
|
||||
export DATABASE_URL="postgresql://webref@localhost:5432/webref"
|
||||
export MINIO_ENDPOINT="localhost:9000"
|
||||
export MINIO_ACCESS_KEY="minioadmin"
|
||||
export MINIO_SECRET_KEY="minioadmin"
|
||||
export PYTHONPATH="$PWD/backend:$PYTHONPATH"
|
||||
export PATH="${pythonEnv}/bin:${pkgs.nodejs}/bin:$PATH"
|
||||
|
||||
# Session name
|
||||
SESSION_NAME="webref-dev"
|
||||
|
||||
# Kill existing session if it exists
|
||||
${pkgs.tmux}/bin/tmux has-session -t $SESSION_NAME 2>/dev/null && ${pkgs.tmux}/bin/tmux kill-session -t $SESSION_NAME
|
||||
|
||||
echo "🚀 Starting development environment in tmux..."
|
||||
echo ""
|
||||
echo "📋 Tmux Controls:"
|
||||
echo " Switch panes: Ctrl+b → arrow keys"
|
||||
echo " Scroll mode: Ctrl+b → ["
|
||||
echo " Exit scroll: q"
|
||||
echo " Detach session: Ctrl+b → d"
|
||||
echo " Kill session: Ctrl+b → :kill-session"
|
||||
echo ""
|
||||
echo "Starting in 2 seconds..."
|
||||
sleep 2
|
||||
|
||||
# Create new tmux session with backend
|
||||
${pkgs.tmux}/bin/tmux new-session -d -s "$SESSION_NAME" -n "webref" -c "$PWD/backend" \
|
||||
"printf '\n🐍 Starting Backend (uvicorn)...\n\n' && ${pythonEnv}/bin/uvicorn app.main:app --reload --host 0.0.0.0 --port 8000; read -p 'Backend stopped. Press Enter to exit...'"
|
||||
|
||||
# Split window vertically and run frontend
|
||||
${pkgs.tmux}/bin/tmux split-window -h -t "$SESSION_NAME":0 -c "$PWD/frontend" \
|
||||
"printf '\n⚡ Starting Frontend (Vite)...\n\n' && ${pkgs.nodejs}/bin/npm run dev; read -p 'Frontend stopped. Press Enter to exit...'"
|
||||
|
||||
# Set pane titles
|
||||
${pkgs.tmux}/bin/tmux select-pane -t "$SESSION_NAME":0.0 -T "Backend (uvicorn)"
|
||||
${pkgs.tmux}/bin/tmux select-pane -t "$SESSION_NAME":0.1 -T "Frontend (vite)"
|
||||
|
||||
# Balance panes
|
||||
${pkgs.tmux}/bin/tmux select-layout -t "$SESSION_NAME":0 even-horizontal
|
||||
|
||||
# Focus on backend pane
|
||||
${pkgs.tmux}/bin/tmux select-pane -t "$SESSION_NAME":0.0
|
||||
|
||||
# Attach to session
|
||||
${pkgs.tmux}/bin/tmux attach-session -t "$SESSION_NAME"
|
||||
''}";
|
||||
};
|
||||
|
||||
# Unified linting - calls both backend and frontend lints
|
||||
lint = {
|
||||
type = "app";
|
||||
|
||||
Reference in New Issue
Block a user