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" <