mirror of
https://github.com/corazoncp/awwwards-testing.git
synced 2026-12-01 04:40:31 +00:00
chore(nix): add Node 24 and Playwright Chromium devShell
- Provide nodejs_24 and Chromium + chromium-headless-shell + ffmpeg via playwright-driver.selectBrowsers - Wrap headless browser entrypoints to unset WAYLAND_DISPLAY so SwANGLE/SwiftShader initializes WebGL2 on Wayland hosts without mutating the shell environment - Export PLAYWRIGHT_BROWSERS_PATH, PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD, PLAYWRIGHT_SKIP_VALIDATE_HOST_REQUIREMENTS, and PLAYWRIGHT_NIX_VERSION - Add direnv .envrc and ignore .direnv/ and node_modules/ Rationale: Generic Linux Chromium downloads from npx playwright install cannot run on NixOS without FHS shared libraries, and Wayland sessions cause SwANGLE to fail with VK_KHR_wayland_surface unsupported unless WAYLAND_DISPLAY is unset for headless browser processes.
This commit is contained in:
1 parent
a8a8fc0f92
commit
b38959bb7c
4 files changed
+99
No files matched your search
@@ -0,0 +1,2 @@
|
||||
.direnv/
|
||||
node_modules/
|
||||
Generated
+24
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1793341285,
|
||||
"narHash": "sha256-LOv16TsMYV2/8BUYnhSxHkOASe7es2ORbqMeLlZJ8Hc=",
|
||||
"rev": "1c89083e451e891152365b799595cf7790a43325",
|
||||
"type": "tarball",
|
||||
"url": "https://releases.nixos.org/nixos/unstable/nixos-26.11pre1105037.1c89083e451e/nixexprs.tar.zst"
|
||||
},
|
||||
"original": {
|
||||
"type": "tarball",
|
||||
"url": "https://channels.nixos.org/nixos-unstable/nixexprs.tar.zst"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
{
|
||||
description = "awwwards-testing dev shell: Node + Nix-provided Playwright Chromium";
|
||||
|
||||
inputs = {
|
||||
# Same channel as ~/Config so store paths are shared with the system.
|
||||
nixpkgs.url = "https://channels.nixos.org/nixos-unstable/nixexprs.tar.zst";
|
||||
};
|
||||
|
||||
outputs =
|
||||
{ nixpkgs, ... }:
|
||||
let
|
||||
system = "x86_64-linux";
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
|
||||
# Chromium + headless shell + ffmpeg (browsers-chromium omits chromium-headless-shell).
|
||||
rawBrowsers = pkgs.playwright-driver.selectBrowsers {
|
||||
withFirefox = false;
|
||||
withWebkit = false;
|
||||
};
|
||||
|
||||
# On Wayland sessions (`WAYLAND_DISPLAY` set), ANGLE's SwANGLE Vulkan backend requests
|
||||
# `VK_KHR_wayland_surface`, which SwiftShader lacks, causing headless WebGL2 to fail with
|
||||
# `EGL_NOT_INITIALIZED`. Wrapping the browser entrypoints to unset `WAYLAND_DISPLAY` only
|
||||
# for headless runs preserves WebGL2 in Playwright while leaving `WAYLAND_DISPLAY` intact
|
||||
# in the interactive shell.
|
||||
browsers = pkgs.runCommand "playwright-browsers-wayland-safe" { } ''
|
||||
mkdir -p "$out"
|
||||
for entry in "${rawBrowsers}"/*; do
|
||||
name="$(basename "$entry")"
|
||||
case "$name" in
|
||||
chromium-[0-9]*)
|
||||
mkdir -p "$out/$name/chrome-linux64"
|
||||
ln -s "$entry/chrome-linux64"/* "$out/$name/chrome-linux64/"
|
||||
rm "$out/$name/chrome-linux64/chrome"
|
||||
cat > "$out/$name/chrome-linux64/chrome" <<EOF
|
||||
#!/bin/sh
|
||||
case " \$* " in
|
||||
*" --headless"*) unset WAYLAND_DISPLAY ;;
|
||||
esac
|
||||
exec "$entry/chrome-linux64/chrome" "\$@"
|
||||
EOF
|
||||
chmod +x "$out/$name/chrome-linux64/chrome"
|
||||
;;
|
||||
chromium_headless_shell-[0-9]*)
|
||||
mkdir -p "$out/$name/chrome-headless-shell-linux64"
|
||||
ln -s "$entry/chrome-headless-shell-linux64"/* "$out/$name/chrome-headless-shell-linux64/"
|
||||
rm "$out/$name/chrome-headless-shell-linux64/chrome-headless-shell"
|
||||
cat > "$out/$name/chrome-headless-shell-linux64/chrome-headless-shell" <<EOF
|
||||
#!/bin/sh
|
||||
unset WAYLAND_DISPLAY
|
||||
exec "$entry/chrome-headless-shell-linux64/chrome-headless-shell" "\$@"
|
||||
EOF
|
||||
chmod +x "$out/$name/chrome-headless-shell-linux64/chrome-headless-shell"
|
||||
;;
|
||||
*)
|
||||
ln -s "$entry" "$out/$name"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
'';
|
||||
in
|
||||
{
|
||||
devShells.${system}.default = pkgs.mkShell {
|
||||
packages = [ pkgs.nodejs_24 ];
|
||||
|
||||
PLAYWRIGHT_BROWSERS_PATH = "${browsers}";
|
||||
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD = "1";
|
||||
PLAYWRIGHT_SKIP_VALIDATE_HOST_REQUIREMENTS = "true";
|
||||
PLAYWRIGHT_NIX_VERSION = pkgs.playwright-driver.version;
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user