diff --git a/flake.nix b/flake.nix index eb13b41..a31c19c 100644 --- a/flake.nix +++ b/flake.nix @@ -22,18 +22,23 @@ pnpm playwright-test ]; + commonEnv = { + PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD = "1"; + PLAYWRIGHT_BROWSERS_PATH = "${pkgs.playwright-driver.browsers}"; + }; in { devShells.default = pkgs.mkShell { inherit buildInputs; shellHook = '' - export PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 - export PLAYWRIGHT_BROWSERS_PATH="${pkgs.playwright-driver.browsers}" + export PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=${commonEnv.PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD} + export PLAYWRIGHT_BROWSERS_PATH=${commonEnv.PLAYWRIGHT_BROWSERS_PATH} ''; }; checks.default = pkgs.runCommand "check-env" { inherit buildInputs; + inherit (commonEnv) PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD PLAYWRIGHT_BROWSERS_PATH; } '' echo "Checking Node.js version..." if ! node --version | grep -q "v22"; then @@ -43,7 +48,27 @@ echo "Checking pnpm availability..." pnpm --version || (echo "pnpm not found" && exit 1) - + + echo "Checking PLAYWRIGHT_BROWSERS_PATH..." + if [ -z "$PLAYWRIGHT_BROWSERS_PATH" ]; then + echo "PLAYWRIGHT_BROWSERS_PATH is not set" + exit 1 + fi + + echo "Checking if PLAYWRIGHT_BROWSERS_PATH exists..." + if [ ! -d "$PLAYWRIGHT_BROWSERS_PATH" ]; then + echo "PLAYWRIGHT_BROWSERS_PATH directory does not exist" + exit 1 + fi + + echo "Checking for specific browsers..." + for browser in chromium firefox webkit; do + if [ ! -d "$PLAYWRIGHT_BROWSERS_PATH/$browser"* ]; then + echo "$browser not found in PLAYWRIGHT_BROWSERS_PATH" + exit 1 + fi + done + touch $out ''; }