Skip to content

Commit a13ba41

Browse files
authored
playwright-driver: use upstream chromium build (#383876)
2 parents b214724 + 9424a47 commit a13ba41

File tree

2 files changed

+124
-29
lines changed

2 files changed

+124
-29
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: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,10 @@ let
149149
description = "Framework for Web Testing and Automation";
150150
homepage = "https://playwright.dev";
151151
license = lib.licenses.asl20;
152-
maintainers = with lib.maintainers; [ kalekseev ];
152+
maintainers = with lib.maintainers; [
153+
kalekseev
154+
marie
155+
];
153156
inherit (nodejs.meta) platforms;
154157
};
155158
};
@@ -174,6 +177,7 @@ let
174177
withWebkit = false;
175178
withChromiumHeadlessShell = false;
176179
};
180+
inherit components;
177181
};
178182
});
179183

@@ -202,6 +206,32 @@ let
202206
};
203207
});
204208

209+
components = {
210+
chromium = callPackage ./chromium.nix {
211+
inherit suffix system throwSystem;
212+
inherit (playwright-core.passthru.browsersJSON.chromium) revision;
213+
fontconfig_file = makeFontsConf {
214+
fontDirectories = [ ];
215+
};
216+
};
217+
chromium-headless-shell = callPackage ./chromium-headless-shell.nix {
218+
inherit suffix system throwSystem;
219+
inherit (playwright-core.passthru.browsersJSON.chromium) revision;
220+
};
221+
firefox = callPackage ./firefox.nix {
222+
inherit suffix system throwSystem;
223+
inherit (playwright-core.passthru.browsersJSON.firefox) revision;
224+
};
225+
webkit = callPackage ./webkit.nix {
226+
inherit suffix system throwSystem;
227+
inherit (playwright-core.passthru.browsersJSON.webkit) revision;
228+
};
229+
ffmpeg = callPackage ./ffmpeg.nix {
230+
inherit suffix system throwSystem;
231+
inherit (playwright-core.passthru.browsersJSON.ffmpeg) revision;
232+
};
233+
};
234+
205235
browsers = lib.makeOverridable (
206236
{
207237
withChromium ? true,
@@ -232,17 +262,7 @@ let
232262
lib.nameValuePair
233263
# TODO check platform for revisionOverrides
234264
"${lib.replaceStrings [ "-" ] [ "_" ] name}-${value.revision}"
235-
(
236-
callPackage (./. + "/${name}.nix") (
237-
{
238-
inherit suffix system throwSystem;
239-
inherit (value) revision;
240-
}
241-
// lib.optionalAttrs (name == "chromium") {
242-
inherit fontconfig_file;
243-
}
244-
)
245-
)
265+
components.${name}
246266
) browsers
247267
)
248268
)

0 commit comments

Comments
 (0)