From b38959bb7cc594dd99ebf7912e7af7a730a94542 Mon Sep 17 00:00:00 2001 From: kiskaadee Date: Sun, 1 Nov 2026 10:09:35 -0500 Subject: [PATCH] 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. --- .envrc | 1 + .gitignore | 2 ++ flake.lock | 24 ++++++++++++++++++ flake.nix | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 99 insertions(+) create mode 100644 .envrc create mode 100644 .gitignore create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0b467cb --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.direnv/ +node_modules/ diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..3cc8a62 --- /dev/null +++ b/flake.lock @@ -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 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..2fc39ab --- /dev/null +++ b/flake.nix @@ -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" < "$out/$name/chrome-headless-shell-linux64/chrome-headless-shell" <