Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 92 additions & 17 deletions pkgs/development/web/playwright/chromium.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,102 @@
suffix,
system,
throwSystem,
lib,
alsa-lib,
at-spi2-atk,
atk,
autoPatchelfHook,
cairo,
cups,
dbus,
expat,
glib,
gobject-introspection,
libGL,
libgbm,
libgcc,
libxkbcommon,
nspr,
nss,
pango,
patchelf,
pciutils,
stdenv,
systemd,
vulkan-loader,
xorg,
...
}:
let
chromium-linux =
runCommand "playwright-chromium"
{
nativeBuildInputs = [
makeWrapper
];
}
''
mkdir -p $out/chrome-linux
chromium-linux = stdenv.mkDerivation {
name = "playwright-chromium";
src = fetchzip {
url = "https://playwright.azureedge.net/builds/chromium/${revision}/chromium-${suffix}.zip";
hash =
{
x86_64-linux = "sha256-9bK8HOGoQY5kYYfJypYHeuAoVlXIh/1tv1IsXPpUTpA=";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this should be sha256-7oQQCAIt1VJiMNFEJO40K8oENK/L0BICXm2D/3fZ8bA= for x86_64-linux.

See: #383876 (comment)

aarch64-linux = "sha256-KL6tYnPDszXjCHiSNOPHLtz839JPljSOoP7biQfTTAI=";
}
.${system} or throwSystem;
};

nativeBuildInputs = [
autoPatchelfHook
patchelf
makeWrapper
];
buildInputs = [
alsa-lib
at-spi2-atk
atk
cairo
cups
dbus
expat
glib
gobject-introspection
libgbm
libgcc
libxkbcommon
nspr
nss
pango
stdenv.cc.cc.lib
systemd
xorg.libX11
xorg.libXcomposite
xorg.libXdamage
xorg.libXext
xorg.libXfixes
xorg.libXrandr
xorg.libxcb
];

installPhase = ''
runHook preInstall

mkdir -p $out/chrome-linux
cp -R . $out/chrome-linux

# See here for the Chrome options:
# https://github.com/NixOS/nixpkgs/issues/136207#issuecomment-908637738
# We add --disable-gpu to be able to run in gpu-less environments such
# as headless nixos test vms.
makeWrapper ${chromium}/bin/chromium $out/chrome-linux/chrome \
--set-default SSL_CERT_FILE /etc/ssl/certs/ca-bundle.crt \
--set-default FONTCONFIG_FILE ${fontconfig_file}
'';
wrapProgram $out/chrome-linux/chrome \
--set-default SSL_CERT_FILE /etc/ssl/certs/ca-bundle.crt \
--set-default FONTCONFIG_FILE ${fontconfig_file}

runHook postInstall
'';

appendRunpaths = lib.makeLibraryPath [
libGL
vulkan-loader
pciutils
];

postFixup = ''
# replace bundled vulkan-loader since we are also already adding our own to RPATH
rm "$out/chrome-linux/libvulkan.so.1"
ln -s -t "$out/chrome-linux" "${lib.getLib vulkan-loader}/lib/libvulkan.so.1"
'';
};
chromium-darwin = fetchzip {
url = "https://playwright.azureedge.net/builds/chromium/${revision}/chromium-${suffix}.zip";
stripRoot = false;
Expand Down
44 changes: 32 additions & 12 deletions pkgs/development/web/playwright/driver.nix
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,10 @@ let
description = "Framework for Web Testing and Automation";
homepage = "https://playwright.dev";
license = lib.licenses.asl20;
maintainers = with lib.maintainers; [ kalekseev ];
maintainers = with lib.maintainers; [
kalekseev
marie
];
inherit (nodejs.meta) platforms;
};
};
Expand All @@ -174,6 +177,7 @@ let
withWebkit = false;
withChromiumHeadlessShell = false;
};
inherit components;
};
});

Expand Down Expand Up @@ -202,6 +206,32 @@ let
};
});

components = {
chromium = callPackage ./chromium.nix {
inherit suffix system throwSystem;
inherit (playwright-core.passthru.browsersJSON.chromium) revision;
fontconfig_file = makeFontsConf {
fontDirectories = [ ];
};
};
chromium-headless-shell = callPackage ./chromium-headless-shell.nix {
inherit suffix system throwSystem;
inherit (playwright-core.passthru.browsersJSON.chromium) revision;
};
firefox = callPackage ./firefox.nix {
inherit suffix system throwSystem;
inherit (playwright-core.passthru.browsersJSON.firefox) revision;
};
webkit = callPackage ./webkit.nix {
inherit suffix system throwSystem;
inherit (playwright-core.passthru.browsersJSON.webkit) revision;
};
ffmpeg = callPackage ./ffmpeg.nix {
inherit suffix system throwSystem;
inherit (playwright-core.passthru.browsersJSON.ffmpeg) revision;
};
};

browsers = lib.makeOverridable (
{
withChromium ? true,
Expand Down Expand Up @@ -232,17 +262,7 @@ let
lib.nameValuePair
# TODO check platform for revisionOverrides
"${lib.replaceStrings [ "-" ] [ "_" ] name}-${value.revision}"
(
callPackage (./. + "/${name}.nix") (
{
inherit suffix system throwSystem;
inherit (value) revision;
}
// lib.optionalAttrs (name == "chromium") {
inherit fontconfig_file;
}
)
)
components.${name}
) browsers
)
)
Expand Down