1{ lib 2, stdenv 3, fetchPypi 4, fetchFromGitHub 5, buildPythonPackage 6, geckodriver 7, urllib3 8, xorg 9, nixosTests 10}: 11 12 13let 14 # Recompiling x_ignore_nofocus.so as the original one dlopen's libX11.so.6 by some 15 # absolute paths. Replaced by relative path so it is found when used in nix. 16 x_ignore_nofocus = 17 fetchFromGitHub { 18 owner = "SeleniumHQ"; 19 repo = "selenium"; 20 rev = "selenium-3.6.0"; 21 sha256 = "13wf4hx4i7nhl4s8xkziwxl0km1j873syrj4amragj6mpip2wn8v"; 22 }; 23in 24 25buildPythonPackage rec { 26 pname = "selenium"; 27 version = "3.141.0"; 28 29 src = fetchPypi { 30 inherit pname version; 31 sha256 = "039hf9knvl4s3hp21bzwsp1g5ri9gxsh504dp48lc6nr1av35byy"; 32 }; 33 34 buildInputs = [xorg.libX11]; 35 36 propagatedBuildInputs = [ 37 geckodriver urllib3 38 ]; 39 40 patchPhase = lib.optionalString stdenv.isLinux '' 41 cp "${x_ignore_nofocus}/cpp/linux-specific/"* . 42 substituteInPlace x_ignore_nofocus.c --replace "/usr/lib/libX11.so.6" "${xorg.libX11.out}/lib/libX11.so.6" 43 cc -c -fPIC x_ignore_nofocus.c -o x_ignore_nofocus.o 44 cc -shared \ 45 -Wl,${if stdenv.isDarwin then "-install_name" else "-soname"},x_ignore_nofocus.so \ 46 -o x_ignore_nofocus.so \ 47 x_ignore_nofocus.o 48 cp -v x_ignore_nofocus.so selenium/webdriver/firefox/${if stdenv.is64bit then "amd64" else "x86"}/ 49 ''; 50 51 passthru.tests = { 52 testing-vaultwarden = nixosTests.vaultwarden; 53 }; 54 55 meta = with lib; { 56 description = "The selenium package is used to automate web browser interaction from Python"; 57 homepage = "http://www.seleniumhq.org"; 58 license = licenses.asl20; 59 maintainers = with maintainers; [ jraygauthier ]; 60 }; 61}