{ pkgs ? import {} }: let isDarwin = pkgs.stdenv.isDarwin; isLinux = pkgs.stdenv.isLinux; commonBuildInputs = with pkgs; [ nodejs_24 nodePackages.pnpm git curl ]; # Dependencies for Playwright's self-downloaded browsers (for macOS) playwrightSelfDownloadLibs = with pkgs; [ glibc libgcc glib nss nspr dbus atk at-spi2-atk at-spi2-core cups expat xorg.libX11 xorg.libxcb xorg.libXext xorg.libXfixes xorg.libXrandr xorg.libXcomposite xorg.libXdamage xorg.libXcursor xorg.libXi xorg.libXrender xorg.libXtst libxkbcommon mesa libglvnd cairo pango fontconfig freetype harfbuzz udev alsa-lib icu libdrm libpng gnutls ]; # Path string for LD_LIBRARY_PATH, only for self-downloaded Playwright playwrightLibPath = pkgs.lib.makeBinPath playwrightSelfDownloadLibs; in pkgs.mkShell { buildInputs = commonBuildInputs ++ ( if isDarwin then playwrightSelfDownloadLibs else [ pkgs.chromium ] ); shellHook = '' echo "🚀 atridotdad development environment loaded!" echo "Node version: $(node --version)" echo "pnpm version: $(pnpm --version)" # Conditional setup for Chromium/Playwright ${if isDarwin then '' # macOS: Playwright downloads its own browser echo "Chromium path: Playwright will download its own for macOS" export PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=0 export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=false export LD_LIBRARY_PATH="${playwrightLibPath}:$LD_LIBRARY_PATH" PLAYWRIGHT_BROWSERS_PATH="$HOME/.cache/ms-playwright" if [ ! -d "$PLAYWRIGHT_BROWSERS_PATH" ] || [ -z "$(ls -A "$PLAYWRIGHT_BROWSERS_PATH")" ]; then echo "🌐 Installing Playwright browsers (for macOS)..." pnpm exec playwright install else echo "✅ Playwright browsers already installed (for macOS)." fi '' else if isLinux then '' # Linux: Use Nixpkgs-provided Chromium echo "Chromium path: ${pkgs.chromium}/bin/chromium" export PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 export PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH="${pkgs.chromium}/bin/chromium" export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true export PUPPETEER_EXECUTABLE_PATH="${pkgs.chromium}/bin/chromium" '' else '' echo "Unsupported OS detected." ''} if [ ! -d "node_modules" ]; then echo "📦 Installing pnpm dependencies..." pnpm install fi ''; # Environment variables PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD = if isDarwin then "0" else "1"; PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH = if isDarwin then null else "${pkgs.chromium}/bin/chromium"; PUPPETEER_SKIP_CHROMIUM_DOWNLOAD = if isDarwin then "false" else "true"; PUPPETEER_EXECUTABLE_PATH = if isDarwin then null else "${pkgs.chromium}/bin/chromium"; }