lol
1{ lib, stdenv, fetchurl, unzip, makeWrapper
2, cairo, fontconfig, freetype, gdk-pixbuf, glib
3, glibc, gtk2, libX11, nspr, nss, pango
4, libxcb, libXi, libXrender, libXext, dbus
5, testers, chromedriver
6}:
7
8let
9 upstream-info = (import ../../../../applications/networking/browsers/chromium/upstream-info.nix).stable.chromedriver;
10 allSpecs = {
11 x86_64-linux = {
12 system = "linux64";
13 hash = upstream-info.hash_linux;
14 };
15
16 x86_64-darwin = {
17 system = "mac-x64";
18 hash = upstream-info.hash_darwin;
19 };
20
21 aarch64-darwin = {
22 system = "mac-arm64";
23 hash = upstream-info.hash_darwin_aarch64;
24 };
25 };
26
27 spec = allSpecs.${stdenv.hostPlatform.system}
28 or (throw "missing chromedriver binary for ${stdenv.hostPlatform.system}");
29
30 libs = lib.makeLibraryPath [
31 stdenv.cc.cc.lib
32 cairo fontconfig freetype
33 gdk-pixbuf glib gtk2
34 libX11 nspr nss pango libXrender
35 libxcb libXext libXi
36 dbus
37 ];
38
39in stdenv.mkDerivation rec {
40 pname = "chromedriver";
41 version = upstream-info.version;
42
43 src = fetchurl {
44 url = "https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/${version}/${spec.system}/chromedriver-${spec.system}.zip";
45 hash = spec.hash;
46 };
47
48 nativeBuildInputs = [ unzip makeWrapper ];
49
50 unpackPhase = "unzip $src";
51
52 installPhase = ''
53 install -m755 -D "chromedriver-${spec.system}/chromedriver" $out/bin/chromedriver
54 '' + lib.optionalString (!stdenv.isDarwin) ''
55 patchelf --set-interpreter ${glibc.out}/lib/ld-linux-x86-64.so.2 $out/bin/chromedriver
56 wrapProgram "$out/bin/chromedriver" --prefix LD_LIBRARY_PATH : "${libs}"
57 '';
58
59 passthru.tests.version = testers.testVersion { package = chromedriver; };
60
61 meta = with lib; {
62 homepage = "https://chromedriver.chromium.org/";
63 description = "A WebDriver server for running Selenium tests on Chrome";
64 longDescription = ''
65 WebDriver is an open source tool for automated testing of webapps across
66 many browsers. It provides capabilities for navigating to web pages, user
67 input, JavaScript execution, and more. ChromeDriver is a standalone
68 server that implements the W3C WebDriver standard.
69 '';
70 sourceProvenance = with sourceTypes; [ binaryNativeCode ];
71 license = licenses.bsd3;
72 maintainers = with maintainers; [ goibhniu marsam primeos ];
73 # Note from primeos: By updating Chromium I also update Google Chrome and
74 # ChromeDriver.
75 platforms = attrNames allSpecs;
76 mainProgram = "chromedriver";
77 };
78}