-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
playwright-test: Add PLAYWRIGHT_BROWSERS_PATH to build environment #368391
base: master
Are you sure you want to change the base?
playwright-test: Add PLAYWRIGHT_BROWSERS_PATH to build environment #368391
Conversation
27dc250
to
ca60ebe
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need --set-default PLAYWRIGHT_BROWSERS_PATH "${playwright-core.passthru.browsers}"
in makeWrapper?
Also the python library needs the same changes.
@@ -191,9 +192,25 @@ let | |||
runHook postInstall | |||
''; | |||
|
|||
setupHook = writeText "setupHook.sh" '' | |||
addBrowsersPath () { | |||
export PLAYWRIGHT_BROWSERS_PATH="${playwright-core.passthru.browsers}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to override this var? if user wants to run his script with different browsers path
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, you can override it as usual (by setting it in the environment before running the script).
I think overlays etc. should still work too? Or do we need to use pkgs.playwright-driver
instead of the local playwright-core
definition to pull in customizations? There's a few references to playwright-core
already...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Playwright package named core
but in nixpkgs it was named driver
initially and we keep it for backward compatibility. Would be nice to migrate to core
eventually but at the moment playwright PRs are waiting for months before someone review and merge them so let's use driver
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I don't mean the name, but whether we're using the definition from pkgs
so that overrides apply. I think that if we want to make packages overridable with things like overlays or overrideAttrs
, then we have to use finalAttrs
or import ourselves and use that to refer to our package instead of using what we defined directly.
Let me try a few things...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I don't see any way to override the browser derivation.
I see that in #344614 the browsers were wrapped in makeOverridable
, but that was so that a user can customize and use just the browsers (by setting PLAYWRIGHT_BROWSERS_PATH
to point to them), not for building a Node or Python package that uses a different set of browsers in its wrapped scripts.
So, it looks like doing it that way was never possible, but we are not making it worse here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to override this var? if user wants to run his script with different browsers path
Actually forgot about the case if the user sets the variable before running nix-shell
(and doesn't use --pure
). Changed it so we set it only if it's unset.
Yes, it's still useful, as that creates a
OK, added. |
@@ -101,6 +112,9 @@ buildPythonPackage rec { | |||
{ | |||
driver = playwright-driver; | |||
browsers = playwright-driver.browsers; | |||
env = runCommand "playwright-env-test" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we already have playwright test that uses python package, I guess we can remove this var in it https://github.com/nixos/nixpkgs/blob/26713f779299cd4688ef2f35e7f19cbc2e207f79/nixos/tests/playwright-python.nix#L15 to test the setupHook
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this change will not apply to that test. There, we don't run Playwright from a derivation directly, but instead use writePython3Bin
which will create a command that we will then run from outside later, with a different environment that won't have that variable.
This allows writing self-contained node scripts (using a nix-shell shebang), without requiring a separate shell.nix which sets PLAYWRIGHT_BROWSERS_PATH to pkgs.playwright-driver.browsers.
…ironment This allows writing self-contained Python scripts (using a nix-shell shebang), without requiring a separate shell.nix which sets PLAYWRIGHT_BROWSERS_PATH to pkgs.playwright-driver.browsers.
cd300c3
to
a1952a6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This allows writing self-contained node scripts (using a
nix-shell
shebang), without requiring a separateshell.nix
which setsPLAYWRIGHT_BROWSERS_PATH
topkgs.playwright-driver.browsers
.Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.