# shell.nix
{
pkgs ? import <nixpkgs> {},
unstable ? import <unstable> { }
}:
pkgs.mkShell {
# nativeBuildInputs is usually what you want -- tools you need to run
# Check last version of playwright https://search.nixos.org/packages?channel=unstable&from=0&size=50&sort=relevance&type=packages&query=playwright-driver
nativeBuildInputs = with pkgs; [
unstable.playwright-driver.browsers
];
shellHook = ''
export PLAYWRIGHT_BROWSERS_PATH=${unstable.playwright-driver.browsers}
export PLAYWRIGHT_SKIP_VALIDATE_HOST_REQUIREMENTS=true
'';
}
The version of playwright in unstable is 1.40.0. But I need to use the last version of playwright : 1.46.1
I wonder how to use the last version with my shell.nix ?
So you are using devenv.nix and a flake.nix file together? How does that work? It looks like what youāve shared is the flakeā¦ is it possible to share the devenv.nix file too?
We are having some issues using just devenv.nix with our Playwright installation (pnpm dependency). Itās a TypeScript project, but when we run pnpm exec playwright test we are seeing this error:
Error: browserType.launch: Executable doesn't exist at /nix/store/lrrc9yfclwvck9q8ng1b3c7560nlv51a-playwright-browsers/chromium_headless_shell-1148/chrome-linux/headless_shell
That location doesnāt exist, but /nix/store/lrrc9yfclwvck9q8ng1b3c7560nlv51a-playwright-browsers/chromium_headless_shell-1148/chrome-linux/chrome does exist.
Yes, thatās a plain flake.nix file, but it is using the devenv repository. You should be able to use it just by running nix develop --impure. In this setup you donāt have a devenv.nix file.
Iām just not sure why you are getting this error with pnpm, for me using npm works just fine. Are you also using devenv? Could you share the flake file you are using?
We werenāt using a flake at all, was using a devenv.nix file. But Iāve converted it to a flake and get the exact same error as when I use the devenv.nix file.
Iāve tried your flake file and got the same error.
After looking into it, it seems that the path is actually āl/nix/store/x2ih0irl5zby5wgyfrcfjkjfkqfgzg28-playwright-browsers/chromium-1134/chrome-linux/chromeā
Itās in chromium-1134 but for some reason playwright is expecting at chromium-1148.
Looking at that made me realize it was a mismatch between the playwright version requested in my package.json file (v1.49.0) and the related driver version supplied by nixpkgs-unstable (v1.47.0). So updating the package.json file resolved the browserType.launch: Executable doesn't exist error.
Unfortunately, the same tests are still failing. But now itās due to:
{ pkgs ? import <nixpkgs> {} }:
let
# We need to pin the version of playwright-driver, so we can match the version in package.json
# See https://www.nixhub.io/packages/playwright-driver for hash
playwrightPkgs = import
(builtins.fetchTarball {
# Currently pinned to: playwright-driver@1.47.0
url = https://github.com/NixOS/nixpkgs/archive/34a626458d686f1b58139620a8b2793e9e123bba.tar.gz;
sha256 = "sha256:1dm43gvl20wbl6j1d6l35y4bqjdspg3xv143ibnbzvv5anw6q2cw";
}) {};
in
pkgs.mkShell {
nativeBuildInputs = with pkgs; [
nodejs
playwrightPkgs.playwright-driver.browsers
jq
];
shellHook = ''
export PLAYWRIGHT_BROWSERS_PATH=${playwrightPkgs.playwright-driver.browsers}
export PLAYWRIGHT_SKIP_VALIDATE_HOST_REQUIREMENTS=true
export PLAYWRIGHT_NODEJS_PATH=${pkgs.nodejs}/bin/node
playwright_chromium_revision="$(${pkgs.jq}/bin/jq --raw-output '.browsers[] | select(.name == "chromium").revision' ${playwrightPkgs.playwright-driver}/browsers.json)"
export PLAYWRIGHT_LAUNCH_OPTIONS_EXECUTABLE_PATH=${playwrightPkgs.playwright-driver.browsers}/chromium-$playwright_chromium_revision/chrome-linux/chrome
env | grep ^PLAYWRIGHT
'';
}
I didnāt need PLAYWRIGHT_LAUNCH_OPTIONS_EXECUTABLE_PATH in the end, and I never got running the tests in VS Code working. The CLI and test UI are working fine.