Skip to content

Commit d715628

Browse files
committed
fixups
1 parent a8338cf commit d715628

4 files changed

Lines changed: 19 additions & 78 deletions

File tree

Makefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,17 @@ DOCKERFILES := \
3939

4040
build: gen go-build node-install
4141

42+
# Note: We only install deps for webkit because full --with-deps fails on newer systems
43+
# (like Ubuntu 24.04) due to virtual package resolution issues (e.g. libasound2).
4244
nix-setup: node-install go-install-tools gen
4345
npx playwright install
46+
npx playwright install-deps webkit
4447

4548
clean: clean-gen clean-node port-forward-terminate minikube-delete
4649

50+
clean-nix:
51+
rm -rf .nix/
52+
4753
precommit: license-check go-fix go-tidy lint test unstaged-changes
4854

4955
################################
@@ -392,7 +398,7 @@ playwright-install:
392398
@if [ -z "$$PLAYWRIGHT_BROWSERS_PATH" ]; then \
393399
npx playwright install --with-deps; \
394400
else \
395-
echo "Skipping playwright install because PLAYWRIGHT_BROWSERS_PATH is set to $$PLAYWRIGHT_BROWSERS_PATH"; \
401+
echo "Skipping playwright install because PLAYWRIGHT_BROWSERS_PATH is set to $$PLAYWRIGHT_BROWSERS_PATH. This should have been handled by nix-develop already to prevent sudo prompt."; \
396402
fi
397403

398404
playwright-update-snapshots: fresh-env-for-playwright

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ nix develop
6060
make nix-setup
6161
```
6262

63+
> [!NOTE]
64+
> To clean up the downloaded browsers and start fresh, you can run `make clean-nix`.
65+
6366
### Running the services locally
6467

6568
After setting up your environment, check out the [DEVELOPMENT.md](./DEVELOPMENT.md) for more information to get started and running locally.

docs/nix-setup.md

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ make nix-setup
2424

2525
This will drop you into a new shell with all the required tools in your `PATH`:
2626

27-
- Go (1.26.1)
28-
- Node.js (24.14.0)
29-
- OpenJDK 25
27+
- Go
28+
- Node.js
29+
- OpenJDK
3030
- Terraform, Cloud SDK, Minikube, Skaffold, etc.
3131

3232
You can verify the versions by looking at the output message when you enter the shell.
@@ -101,32 +101,15 @@ Instead, rely entirely on your host shell's `direnv` hook:
101101

102102
Now, whenever you open a new integrated terminal in VS Code, your shell will automatically load the Nix environment _after_ initialization, ensuring all tools are available.
103103

104-
## Playwright WebKit on Nix
105-
106-
Playwright's WebKit browser requires some special handling in a Nix environment because it expects libraries that may not match the default versions in Nixpkgs.
107-
108-
We have handled this in `flake.nix`:
104+
## Playwright and Browsers
109105

110-
1. **Correct Library Versions**: We use `libxml2_13` instead of the default `libxml2` because it provides the exact `libxml2.so.2` file WebKit expects, avoiding brittle symlink hacks.
111-
2. **Automatic Patching**: When you enter the shell (`nix develop`), it automatically checks if Playwright browsers are installed in `.nix/browsers`. If found, it patches the `MiniBrowser` wrapper script to preserve your `LD_LIBRARY_PATH` instead of overwriting it.
106+
Playwright manages its own browser binaries and system dependencies.
112107

113-
### Clean Build of the Environment
108+
When you run `make nix-setup`, it runs `npx playwright install` to download browsers, and `npx playwright install-deps webkit` to install system dependencies for WebKit on the host.
114109

115-
If you run into issues with browsers or want to ensure a clean setup:
110+
We only install dependencies for `webkit` because a full `--with-deps` can fail on newer Linux distributions (like Ubuntu 24.04) due to package name changes (e.g., `libasound2` being replaced by `libasound2t64`).
116111

117-
1. **Clean Playwright Cache**: Delete the cached browsers to force a redownload.
118-
```bash
119-
rm -rf .nix/browsers
120-
```
121-
2. **Re-install Browsers**: Run the install command again (inside `nix develop`).
122-
```bash
123-
npx playwright install
124-
```
125-
3. **Re-enter Shell**: Exit and re-enter `nix develop` to trigger the automatic patching again!
126-
```bash
127-
exit
128-
nix develop
129-
```
112+
This ensures that browsers work correctly without needing complex configuration or patching in the Nix flake.
130113

131114
## Playwright E2E Tests and Docker
132115

flake.nix

Lines changed: 1 addition & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -38,43 +38,7 @@
3838
netcat
3939
antlr4
4040

41-
# Libraries needed for Playwright browsers (added for WebKit, might help others)
42-
mesa
43-
libGL
44-
libxkbcommon
45-
wayland
46-
enchant_2
47-
libsecret
48-
libgudev
49-
gst_all_1.gstreamer
50-
gst_all_1.gst-plugins-base
51-
gst_all_1.gst-plugins-good
52-
atk
53-
at-spi2-atk
54-
at-spi2-core
55-
cups
56-
dbus
57-
glib
58-
gtk3
59-
pango
60-
cairo
61-
expat
62-
libdrm
63-
fontconfig
64-
freetype
65-
libx11
66-
libxcomposite
67-
libxdamage
68-
libxext
69-
libxfixes
70-
libxrandr
71-
libxcb
72-
libxshmfence
73-
libxtst
74-
libxi
75-
libxcursor
76-
libxml2_13
77-
libevent
41+
7842
];
7943

8044
shellHook = ''
@@ -83,24 +47,9 @@
8347
export DOCKER_BUILDKIT=1
8448
export ANTLR=antlr4
8549
export USE_DOCKER_BROWSER=true
86-
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${pkgs.libxml2_13.out}/lib:${pkgs.libevent.out}/lib"
87-
8850
# Isolate Playwright browsers to this project
8951
export PLAYWRIGHT_BROWSERS_PATH="$PWD/.nix/browsers"
9052
91-
# Automate patching Playwright WebKit for Nix
92-
WEBKIT_DIR=$(find "$PLAYWRIGHT_BROWSERS_PATH" -name "webkit-*" -type d 2>/dev/null | head -n 1)
93-
if [ -n "$WEBKIT_DIR" ]; then
94-
find "$WEBKIT_DIR" -name "MiniBrowser" -type f | while read -r wrapper; do
95-
if [ -f "$wrapper" ]; then
96-
if ! grep -q '\$LD_LIBRARY_PATH' "$wrapper"; then
97-
echo "Patching Playwright WebKit wrapper $wrapper to preserve LD_LIBRARY_PATH..."
98-
sed -i 's|export LD_LIBRARY_PATH="''${MYDIR}/lib:''${MYDIR}/sys/lib"|export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:''${MYDIR}/lib:''${MYDIR}/sys/lib"|' "$wrapper"
99-
fi
100-
fi
101-
done
102-
fi
103-
10453
echo "Entering Nix environment for webstatus.dev"
10554
10655
# Print versions

0 commit comments

Comments
 (0)