diff --git a/pkgs/development/web/playwright/chromium.nix b/pkgs/development/web/playwright/chromium.nix index 31f6686c8e71a..ffc93fc2a18cb 100644 --- a/pkgs/development/web/playwright/chromium.nix +++ b/pkgs/development/web/playwright/chromium.nix @@ -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="; + 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; diff --git a/pkgs/development/web/playwright/driver.nix b/pkgs/development/web/playwright/driver.nix index f924ccac5b104..7d714b9f14f01 100644 --- a/pkgs/development/web/playwright/driver.nix +++ b/pkgs/development/web/playwright/driver.nix @@ -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; }; }; @@ -174,6 +177,7 @@ let withWebkit = false; withChromiumHeadlessShell = false; }; + inherit components; }; }); @@ -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, @@ -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 ) )