Skip to content
Merged
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
10 changes: 6 additions & 4 deletions pkgs/by-name/pl/playwright-mcp/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ buildNpmPackage rec {

npmDepsHash = "sha256-Qsln4llNpfXYXhSEfHnvdsFIF7adHKEyC1eGHtVY2Qk=";

# Codex MCP smoke test (after `codex mcp add playwright-nix --env DISPLAY=:0 -- $out/bin/mcp-server-playwright --headless --isolated`):
# timeout 45s codex exec --dangerously-bypass-approvals-and-sandbox --skip-git-repo-check "Use only playwright-nix MCP tools. Navigate to https://example.com and return only the page title."
postInstall = ''
rm -r $out/lib/node_modules/@playwright/mcp/node_modules/playwright
rm -r $out/lib/node_modules/@playwright/mcp/node_modules/playwright-core
ln -s ${playwright-test}/lib/node_modules/playwright $out/lib/node_modules/@playwright/mcp/node_modules/playwright
ln -s ${playwright-test}/lib/node_modules/playwright-core $out/lib/node_modules/@playwright/mcp/node_modules/playwright-core
rm -rf "$out/lib/node_modules/@playwright/mcp/node_modules/playwright"
rm -rf "$out/lib/node_modules/@playwright/mcp/node_modules/playwright-core"
ln -s ${playwright-test}/lib/node_modules/playwright "$out/lib/node_modules/@playwright/mcp/node_modules/playwright"
ln -s ${playwright-test}/lib/node_modules/playwright-core "$out/lib/node_modules/@playwright/mcp/node_modules/playwright-core"

wrapProgram $out/bin/mcp-server-playwright \
--set PLAYWRIGHT_BROWSERS_PATH ${playwright-driver.browsers} \
Expand Down
78 changes: 40 additions & 38 deletions pkgs/development/python-modules/playwright/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,43 @@
lib,
stdenv,
buildPythonPackage,
fetchFromGitHub,

# patches
replaceVars,
nodejs,
playwright-driver,

# build-system
setuptools,
setuptools-scm,

# nativeBuildInputs
gitMinimal,
writableTmpDirAsHomeHook,

# dependencies
greenlet,
fetchFromGitHub,
pyee,

python,
setuptools,
setuptools-scm,
playwright-driver,
nixosTests,
nodejs,
}:

let
driver = playwright-driver;
in
buildPythonPackage rec {
buildPythonPackage (finalAttrs: {
pname = "playwright";
# run ./pkgs/development/python-modules/playwright/update.sh to update
version = "1.57.0";
# run ./pkgs/development/web/playwright/update.sh to update
version = "1.58.0";
pyproject = true;

src = fetchFromGitHub {
owner = "microsoft";
repo = "playwright-python";
tag = "v${version}";
hash = "sha256-LXTMVC6ytjo7l0QDkNPxtoMTYjmYMjCVqHz61BgAn6A=";
tag = "v${finalAttrs.version}";
hash = "sha256-gK19pjB8TDy/kK+fb4pjwlGZlUyY26p+CNxunvIMrrY=";
};

patches = [
Expand All @@ -36,42 +47,39 @@ buildPythonPackage rec {
# - The setup script, which would try to download the driver package from
# a CDN and patch wheels so that they include it. We don't want this
# we have our own driver build.
./driver-location.patch
(replaceVars ./driver-location.patch {
driver = "${driver}/cli.js";
nodejs = lib.getExe nodejs;
})
];

postPatch = ''
# if setuptools_scm is not listing files via git almost all python files are excluded
export HOME=$(mktemp -d)
git init .
git add -A .
git config --global user.email "nixpkgs"
git config --global user.name "nixpkgs"
git commit -m "workaround setuptools-scm"

sed -i -e 's/requires = \["setuptools==.*", "setuptools-scm==.*", "wheel==.*", "auditwheel==.*"\]/requires = ["setuptools", "setuptools-scm", "wheel"]/' pyproject.toml
substituteInPlace pyproject.toml \
--replace-fail ', "auditwheel==6.2.0"' "" \
--replace-fail "setuptools-scm==8.3.1" "setuptools-scm" \
--replace-fail "setuptools==80.9.0" "setuptools" \
--replace-fail "wheel==0.45.1" "wheel"

# setup.py downloads and extracts the driver.
# This is done manually in postInstall instead.
rm setup.py

# Set the correct driver path with the help of a patch in patches
substituteInPlace playwright/_impl/_driver.py \
--replace-fail "@node@" "${lib.getExe nodejs}" \
--replace-fail "@driver@" "${driver}/cli.js"
'';

nativeBuildInputs = [
gitMinimal
build-system = [
setuptools-scm
setuptools
];

nativeBuildInputs = [
gitMinimal
writableTmpDirAsHomeHook
];

pythonRelaxDeps = [
"greenlet"
"pyee"
];

propagatedBuildInputs = [
dependencies = [
greenlet
pyee
];
Expand All @@ -88,7 +96,7 @@ buildPythonPackage rec {
passthru = {
inherit driver;
tests = {
driver = playwright-driver;
inherit driver;
browsers = playwright-driver.browsers;
}
// lib.optionalAttrs stdenv.hostPlatform.isLinux {
Expand All @@ -97,7 +105,6 @@ buildPythonPackage rec {
# Package and playwright driver versions are tightly coupled.
# Use the update script to ensure synchronized updates.
skipBulkUpdate = true;
updateScript = ./update.sh;
};

meta = {
Expand All @@ -108,12 +115,7 @@ buildPythonPackage rec {
maintainers = with lib.maintainers; [
techknowlogick
yrd
];
platforms = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
kalekseev
];
};
}
})
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/playwright/_impl/_driver.py b/playwright/_impl/_driver.py
index 22b53b8..2d86626 100644
index 22b53b8..43fdbd5 100644
--- a/playwright/_impl/_driver.py
+++ b/playwright/_impl/_driver.py
@@ -23,14 +23,7 @@ from playwright._repo_version import version
Expand All @@ -14,7 +14,7 @@ index 22b53b8..2d86626 100644
- cli_path,
- )
- return (os.getenv("PLAYWRIGHT_NODEJS_PATH", str(driver_path / "node")), cli_path)
+ return "@node@", "@driver@"
+ return "@nodejs@", "@driver@"


def get_driver_env() -> dict:
140 changes: 0 additions & 140 deletions pkgs/development/python-modules/playwright/update.sh

This file was deleted.

Loading
Loading