Skip to content

Commit 23b7080

Browse files
committed
fix(nix): pin playwright to nixpkgs version
Playwright doesn't play that nice with NixOS because it downloads binaries that require libs that aren't always available. Nix has a special package with playwright browsers. We don't use the latest features of Playwright, so lagging behind is fine and it limits the downloads required.
1 parent 55d518e commit 23b7080

File tree

5 files changed

+54
-23
lines changed

5 files changed

+54
-23
lines changed

.envrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1+
# shellcheck shell=bash
12
use flake
2-
PATH_add ./node_modules/.bin
33
watch_file rust-toolchain

flake.lock

+7-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

+25-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
1+
# This is a Nix configuration file. It is used to define the environment
2+
# for the project. It is a declarative way to define the dependencies.
3+
# It is used by the `nix develop` command to create a development environment
4+
# with all the dependencies needed for the project.
5+
6+
# To update the dependencies, run `nix flake update`.
7+
8+
# Note: keep the playwright version in package.json syncpack the same as the nix version
9+
# We don't need to have the latest playwright all the time so not having to download
10+
# all the browsers on every version bump is a good thing.
111
{
212
inputs = {
3-
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
13+
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
414
rust-overlay.url = "github:oxalica/rust-overlay";
515
};
616

@@ -23,6 +33,9 @@
2333
nodejs_20
2434
corepack_20
2535

36+
# Playwright for the end-to-end tests
37+
playwright-driver.browsers
38+
2639
# Qwik optimizer deps
2740
wasm-pack
2841
# Provides rustc and cargo
@@ -34,6 +47,17 @@
3447
targets = [ "wasm32-unknown-unknown" ];
3548
})
3649
];
50+
# https://github.com/microsoft/playwright/issues/5501
51+
shellHook = ''
52+
export PATH=$PWD/node_modules/.bin:$PATH
53+
export PLAYWRIGHT_BROWSERS_PATH=${pkgs.playwright-driver.browsers}
54+
export PLAYWRIGHT_SKIP_VALIDATE_HOST_REQUIREMENTS=true
55+
pwNixVersion=${pkgs.playwright-driver.version}
56+
pwNpmVersion=$(${pkgs.jq}/bin/jq -r .version node_modules/@playwright/test/package.json 2>/dev/null)
57+
if [ -n "$pwNpmVersion" ] && [ "$pwNpmVersion" != "$pwNixVersion" ]; then
58+
echo "!!! Playwright version mismatch: $pwNpmVersion (nodejs) != $pwNixVersion (nix). Please fix." >&2
59+
fi
60+
'';
3761
};
3862
};
3963
in

package.json

+8-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@
2121
"!local"
2222
],
2323
"pinVersion": "workspace:^"
24+
},
25+
{
26+
"label": "Playwright should have the same version as in flake.nix",
27+
"dependencies": [
28+
"@playwright/test"
29+
],
30+
"pinVersion": "1.40.0"
2431
}
2532
],
2633
"semverGroups": [
@@ -67,7 +74,7 @@
6774
"@napi-rs/triples": "^1.2.0",
6875
"@node-rs/helper": "^1.5.0",
6976
"@octokit/action": "6.0.7",
70-
"@playwright/test": "^1.42.1",
77+
"@playwright/test": "1.40.0",
7178
"@types/brotli": "^1.3.4",
7279
"@types/bun": "^1.1.0",
7380
"@types/cross-spawn": "^6.0.6",

pnpm-lock.yaml

+13-13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)