about summary refs log tree commit diff
path: root/pkgs/by-name/un/undetected-chromedriver/package.nix
blob: 3976f3cc685b4b160d9efc732a426aa59e54b97c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
{
  lib,
  stdenv,

  chromedriver,
  python3,

  testers,
  undetected-chromedriver,
}:

stdenv.mkDerivation {
  pname = "undetected-chromedriver";
  inherit (chromedriver) version;

  nativeBuildInputs = [ (python3.withPackages (ps: [ ps.undetected-chromedriver ])) ];

  buildCommand = ''
    export HOME=$(mktemp -d)

    cp ${chromedriver}/bin/chromedriver .
    chmod +w chromedriver

    python <<EOF
    import logging
    from undetected_chromedriver.patcher import Patcher

    logging.basicConfig(level=logging.DEBUG)

    success = Patcher(executable_path="chromedriver").patch()
    assert success, "Failed to patch ChromeDriver"
    EOF

    install -D -m 0555 chromedriver $out/bin/undetected-chromedriver
  '';

  passthru.tests.version = testers.testVersion { package = undetected-chromedriver; };

  meta = chromedriver.meta // {
    description = "Custom Selenium ChromeDriver that passes all bot mitigation systems";
    mainProgram = "undetected-chromedriver";
    maintainers = with lib.maintainers; [ paveloom ];
  };
}