Ok THIS nix shell should work across architectures now... that was a huge issue earlier.
All checks were successful
Docker Deploy / build-and-push (push) Successful in 3m35s
All checks were successful
Docker Deploy / build-and-push (push) Successful in 3m35s
This commit is contained in:
106
shell.nix
106
shell.nix
@ -1,38 +1,108 @@
|
||||
{ pkgs ? import <nixpkgs> {} }:
|
||||
|
||||
pkgs.mkShell {
|
||||
buildInputs = with pkgs; [
|
||||
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)"
|
||||
|
||||
# Always allow Playwright/Puppeteer to download their own browsers
|
||||
export PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=0
|
||||
export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=false
|
||||
|
||||
|
||||
# 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
|
||||
|
||||
# Check if Playwright browsers are installed and install them if not
|
||||
PLAYWRIGHT_BROWSERS_PATH="$HOME/.cache/ms-playwright"
|
||||
if [ ! -d "$PLAYWRIGHT_BROWSERS_PATH" ] || [ -z "$(ls -A "$PLAYWRIGHT_BROWSERS_PATH")" ]; then
|
||||
echo "🌐 Installing Playwright browsers..."
|
||||
pnpm exec playwright install --with-deps # --with-deps ensures all necessary drivers/libraries are also fetched
|
||||
else
|
||||
echo "✅ Playwright browsers already installed."
|
||||
fi
|
||||
'';
|
||||
|
||||
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD = "0";
|
||||
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD = "false";
|
||||
# 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";
|
||||
}
|
Reference in New Issue
Block a user