Skip to content

Commit 18f3489

Browse files
committed
playwright-driver: use upstream chromium build
Use the exact chromium version upstream uses for playwright, to prevent breaking from browser updates in nixpkgs.
1 parent 6209220 commit 18f3489

File tree

2 files changed

+120
-28
lines changed

2 files changed

+120
-28
lines changed

pkgs/development/web/playwright/chromium.nix

Lines changed: 92 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,102 @@
88
suffix,
99
system,
1010
throwSystem,
11+
lib,
12+
alsa-lib,
13+
at-spi2-atk,
14+
atk,
15+
autoPatchelfHook,
16+
cairo,
17+
cups,
18+
dbus,
19+
expat,
20+
glib,
21+
gobject-introspection,
22+
libGL,
23+
libgbm,
24+
libgcc,
25+
libxkbcommon,
26+
nspr,
27+
nss,
28+
pango,
29+
patchelf,
30+
pciutils,
31+
stdenv,
32+
systemd,
33+
vulkan-loader,
34+
xorg,
1135
...
1236
}:
1337
let
14-
chromium-linux =
15-
runCommand "playwright-chromium"
16-
{
17-
nativeBuildInputs = [
18-
makeWrapper
19-
];
20-
}
21-
''
22-
mkdir -p $out/chrome-linux
38+
chromium-linux = stdenv.mkDerivation {
39+
name = "playwright-chromium";
40+
src = fetchzip {
41+
url = "https://playwright.azureedge.net/builds/chromium/${revision}/chromium-${suffix}.zip";
42+
hash =
43+
{
44+
x86_64-linux = "sha256-9bK8HOGoQY5kYYfJypYHeuAoVlXIh/1tv1IsXPpUTpA=";
45+
aarch64-linux = "sha256-KL6tYnPDszXjCHiSNOPHLtz839JPljSOoP7biQfTTAI=";
46+
}
47+
.${system} or throwSystem;
48+
};
49+
50+
nativeBuildInputs = [
51+
autoPatchelfHook
52+
patchelf
53+
makeWrapper
54+
];
55+
buildInputs = [
56+
alsa-lib
57+
at-spi2-atk
58+
atk
59+
cairo
60+
cups
61+
dbus
62+
expat
63+
glib
64+
gobject-introspection
65+
libgbm
66+
libgcc
67+
libxkbcommon
68+
nspr
69+
nss
70+
pango
71+
stdenv.cc.cc.lib
72+
systemd
73+
xorg.libX11
74+
xorg.libXcomposite
75+
xorg.libXdamage
76+
xorg.libXext
77+
xorg.libXfixes
78+
xorg.libXrandr
79+
xorg.libxcb
80+
];
81+
82+
installPhase = ''
83+
runHook preInstall
84+
85+
mkdir -p $out/chrome-linux
86+
cp -R . $out/chrome-linux
2387
24-
# See here for the Chrome options:
25-
# https://github.com/NixOS/nixpkgs/issues/136207#issuecomment-908637738
26-
# We add --disable-gpu to be able to run in gpu-less environments such
27-
# as headless nixos test vms.
28-
makeWrapper ${chromium}/bin/chromium $out/chrome-linux/chrome \
29-
--set-default SSL_CERT_FILE /etc/ssl/certs/ca-bundle.crt \
30-
--set-default FONTCONFIG_FILE ${fontconfig_file}
31-
'';
88+
wrapProgram $out/chrome-linux/chrome \
89+
--set-default SSL_CERT_FILE /etc/ssl/certs/ca-bundle.crt \
90+
--set-default FONTCONFIG_FILE ${fontconfig_file}
91+
92+
runHook postInstall
93+
'';
94+
95+
appendRunpaths = lib.makeLibraryPath [
96+
libGL
97+
vulkan-loader
98+
pciutils
99+
];
100+
101+
postFixup = ''
102+
# replace bundled vulkan-loader since we are also already adding our own to RPATH
103+
rm "$out/chrome-linux/libvulkan.so.1"
104+
ln -s -t "$out/chrome-linux" "${lib.getLib vulkan-loader}/lib/libvulkan.so.1"
105+
'';
106+
};
32107
chromium-darwin = fetchzip {
33108
url = "https://playwright.azureedge.net/builds/chromium/${revision}/chromium-${suffix}.zip";
34109
stripRoot = false;

pkgs/development/web/playwright/driver.nix

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ let
165165
withWebkit = false;
166166
withChromiumHeadlessShell = false;
167167
};
168+
inherit components;
168169
};
169170
});
170171

@@ -193,6 +194,32 @@ let
193194
};
194195
});
195196

197+
components = {
198+
chromium = callPackage ./chromium.nix {
199+
inherit suffix system throwSystem;
200+
inherit (playwright-core.passthru.browsersJSON.chromium) revision;
201+
fontconfig_file = makeFontsConf {
202+
fontDirectories = [ ];
203+
};
204+
};
205+
chromium-headless-shell = callPackage ./chromium-headless-shell.nix {
206+
inherit suffix system throwSystem;
207+
inherit (playwright-core.passthru.browsersJSON.chromium) revision;
208+
};
209+
firefox = callPackage ./firefox.nix {
210+
inherit suffix system throwSystem;
211+
inherit (playwright-core.passthru.browsersJSON.firefox) revision;
212+
};
213+
webkit = callPackage ./webkit.nix {
214+
inherit suffix system throwSystem;
215+
inherit (playwright-core.passthru.browsersJSON.webkit) revision;
216+
};
217+
ffmpeg = callPackage ./ffmpeg.nix {
218+
inherit suffix system throwSystem;
219+
inherit (playwright-core.passthru.browsersJSON.ffmpeg) revision;
220+
};
221+
};
222+
196223
browsers = lib.makeOverridable (
197224
{
198225
withChromium ? true,
@@ -223,17 +250,7 @@ let
223250
lib.nameValuePair
224251
# TODO check platform for revisionOverrides
225252
"${lib.replaceStrings [ "-" ] [ "_" ] name}-${value.revision}"
226-
(
227-
callPackage (./. + "/${name}.nix") (
228-
{
229-
inherit suffix system throwSystem;
230-
inherit (value) revision;
231-
}
232-
// lib.optionalAttrs (name == "chromium") {
233-
inherit fontconfig_file;
234-
}
235-
)
236-
)
253+
components.${name}
237254
) browsers
238255
)
239256
)

0 commit comments

Comments
 (0)