diff --git a/nix/shell.nix b/nix/shell.nix index f6de96cb..34f29da3 100644 --- a/nix/shell.nix +++ b/nix/shell.nix @@ -282,45 +282,53 @@ mkShell { # Ensure Erlang can find NIF libraries export ERL_AFLAGS="-kernel shell_history enabled" - # Install Hex and Rebar3 if not already installed - mix local.hex --force --if-missing > /dev/null 2>&1 - mix local.rebar --force --if-missing > /dev/null 2>&1 + # Skip heavy setup when running inside direnv (DIRENV_DIR is set). + # direnv evaluates the shellHook to load env vars only; running mix, + # starting services, or installing pre-commit hooks would block the + # prompt and cause nix profile cleanup hangs on macOS. + if [ -z "$DIRENV_DIR" ]; then + # Running in nix develop (interactive shell) - # Auto-start services on first shell entry - if [ ! -f "${servicesFlag}" ]; then - ${startServices}/bin/start-services + # Install Hex and Rebar3 if not already installed + mix local.hex --force --if-missing > /dev/null 2>&1 + mix local.rebar --force --if-missing > /dev/null 2>&1 - # Run migrations if databases exist and Mix deps are available - if [ -d "deps" ] && mix ecto.migrate 2>/dev/null; then - echo "✓ Database migrations applied" + # Auto-start services on first shell entry + if [ ! -f "${servicesFlag}" ]; then + ${startServices}/bin/start-services + + # Run migrations if databases exist and Mix deps are available + if [ -d "deps" ] && mix ecto.migrate 2>/dev/null; then + echo "✓ Database migrations applied" + fi fi + + # Install pre-commit hooks + ${pre-commit-check.shellHook} + + # Welcome message + echo "" + echo -e "''${BLUE}╔═══════════════════════════════════════════════════════════╗''${NC}" + echo -e "''${BLUE}║ ║''${NC}" + echo -e "''${BLUE}║''${NC} ''${GREEN}Towerops Development Environment''${NC} ''${BLUE}║''${NC}" + echo -e "''${BLUE}║ ║''${NC}" + echo -e "''${BLUE}╚═══════════════════════════════════════════════════════════╝''${NC}" + echo "" + echo -e "''${GREEN}Available commands:''${NC}" + echo " mix phx.server - Start Phoenix development server" + echo " mix test - Run test suite" + echo " mix precommit - Run pre-commit checks (format, credo, test)" + echo " start-services - Start PostgreSQL and Redis" + echo " stop-services - Stop PostgreSQL and Redis" + echo " mix ecto.reset - Reset database (drop, create, migrate, seed)" + echo "" + echo -e "''${GREEN}Services:''${NC}" + echo " PostgreSQL: ${pgHost}:${pgPort}" + echo " Redis: ${pgHost}:${redisPort}" + echo "" + echo -e "''${GREEN}Documentation:''${NC}" + echo " See CLAUDE.md and docs/nix.md for more information" + echo "" fi - - # Install pre-commit hooks - ${pre-commit-check.shellHook} - - # Welcome message - echo "" - echo -e "''${BLUE}╔═══════════════════════════════════════════════════════════╗''${NC}" - echo -e "''${BLUE}║ ║''${NC}" - echo -e "''${BLUE}║''${NC} ''${GREEN}Towerops Development Environment''${NC} ''${BLUE}║''${NC}" - echo -e "''${BLUE}║ ║''${NC}" - echo -e "''${BLUE}╚═══════════════════════════════════════════════════════════╝''${NC}" - echo "" - echo -e "''${GREEN}Available commands:''${NC}" - echo " mix phx.server - Start Phoenix development server" - echo " mix test - Run test suite" - echo " mix precommit - Run pre-commit checks (format, credo, test)" - echo " start-services - Start PostgreSQL and Redis" - echo " stop-services - Stop PostgreSQL and Redis" - echo " mix ecto.reset - Reset database (drop, create, migrate, seed)" - echo "" - echo -e "''${GREEN}Services:''${NC}" - echo " PostgreSQL: ${pgHost}:${pgPort}" - echo " Redis: ${pgHost}:${redisPort}" - echo "" - echo -e "''${GREEN}Documentation:''${NC}" - echo " See CLAUDE.md and docs/nix.md for more information" - echo "" ''; }