-
-
Notifications
You must be signed in to change notification settings - Fork 19.4k
playwright: fix firefox #197899
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: fix firefox #197899
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -3,13 +3,14 @@ | |||||||||||||||||||||||||
| , buildPythonPackage | ||||||||||||||||||||||||||
| , chromium | ||||||||||||||||||||||||||
| , ffmpeg | ||||||||||||||||||||||||||
| , firefox | ||||||||||||||||||||||||||
| , firefox-bin | ||||||||||||||||||||||||||
| , git | ||||||||||||||||||||||||||
| , greenlet | ||||||||||||||||||||||||||
| , jq | ||||||||||||||||||||||||||
| , nodejs | ||||||||||||||||||||||||||
| , fetchFromGitHub | ||||||||||||||||||||||||||
| , fetchurl | ||||||||||||||||||||||||||
| , fetchzip | ||||||||||||||||||||||||||
| , makeFontsConf | ||||||||||||||||||||||||||
| , makeWrapper | ||||||||||||||||||||||||||
| , pyee | ||||||||||||||||||||||||||
|
|
@@ -21,7 +22,10 @@ | |||||||||||||||||||||||||
| }: | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| let | ||||||||||||||||||||||||||
| inherit (builtins) fromJSON readFile listToAttrs; | ||||||||||||||||||||||||||
| inherit (stdenv.hostPlatform) system; | ||||||||||||||||||||||||||
| selectSystem = attrs: | ||||||||||||||||||||||||||
| attrs.${system} or (throw "Unsupported system: ${system}"); | ||||||||||||||||||||||||||
|
Comment on lines
+27
to
+28
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||
| throwSystem = throw "Unsupported system: ${system}"; | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| driverVersion = "1.27.1"; | ||||||||||||||||||||||||||
|
|
@@ -79,6 +83,22 @@ let | |||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| browser_revs = | ||||||||||||||||||||||||||
| let | ||||||||||||||||||||||||||
| file = fetchurl { | ||||||||||||||||||||||||||
| url = | ||||||||||||||||||||||||||
| "https://raw.githubusercontent.com/microsoft/playwright/v${driverVersion}/packages/playwright-core/browsers.json"; | ||||||||||||||||||||||||||
|
Comment on lines
+89
to
+90
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||
| sha256 = "11a1n65l43nfyjn0qrsjjyjl7psvqa67k4kiv8x624faga4zl3mk"; | ||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||
| raw_data = fromJSON (readFile file); | ||||||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||
| in | ||||||||||||||||||||||||||
| listToAttrs (map | ||||||||||||||||||||||||||
| ({ name, revision, ... }: { | ||||||||||||||||||||||||||
| inherit name; | ||||||||||||||||||||||||||
| value = revision; | ||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||
| raw_data.browsers); | ||||||||||||||||||||||||||
|
Comment on lines
+95
to
+100
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| browsers-mac = stdenv.mkDerivation { | ||||||||||||||||||||||||||
| pname = "playwright-browsers"; | ||||||||||||||||||||||||||
| version = driverVersion; | ||||||||||||||||||||||||||
|
|
@@ -105,6 +125,20 @@ let | |||||||||||||||||||||||||
| fontconfig = makeFontsConf { | ||||||||||||||||||||||||||
| fontDirectories = []; | ||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||
| suffix = selectSystem { | ||||||||||||||||||||||||||
| # Not sure how other system compatibility is, needs trial & error | ||||||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
thats fine :) |
||||||||||||||||||||||||||
| x86_64-linux = "ubuntu-20.04"; | ||||||||||||||||||||||||||
| aarch64-linux = "ubuntu-20.04-arm64"; | ||||||||||||||||||||||||||
| x86_64-darwin = "mac"; | ||||||||||||||||||||||||||
| aarch64-darwin = "mac-arm64"; | ||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| upstream_firefox = fetchzip { | ||||||||||||||||||||||||||
| url = | ||||||||||||||||||||||||||
| "https://playwright.azureedge.net/builds/firefox/${browser_revs.firefox}/firefox-${suffix}.zip"; | ||||||||||||||||||||||||||
|
Comment on lines
+137
to
+138
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||
| sha256 = "sha256-r1cCXxkIABU5BLP1Q6TBoE5CrNhmHApAEZT3ta+GaAU="; | ||||||||||||||||||||||||||
| stripRoot = true; | ||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||
| in runCommand ("playwright-browsers" | ||||||||||||||||||||||||||
| + lib.optionalString (withFirefox && !withChromium) "-firefox" | ||||||||||||||||||||||||||
| + lib.optionalString (!withFirefox && withChromium) "-chromium") | ||||||||||||||||||||||||||
|
|
@@ -125,9 +159,29 @@ let | |||||||||||||||||||||||||
| --set SSL_CERT_FILE /etc/ssl/certs/ca-bundle.crt \ | ||||||||||||||||||||||||||
| --set FONTCONFIG_FILE ${fontconfig} | ||||||||||||||||||||||||||
| '' + lib.optionalString withFirefox '' | ||||||||||||||||||||||||||
| FIREFOX_REVISION=$(jq -r '.browsers[] | select(.name == "firefox").revision' $BROWSERS_JSON) | ||||||||||||||||||||||||||
| mkdir -p $out/firefox-$FIREFOX_REVISION/firefox | ||||||||||||||||||||||||||
| ln -s ${firefox}/bin/firefox $out/firefox-$FIREFOX_REVISION/firefox/firefox | ||||||||||||||||||||||||||
| firefoxoutdir=$out/firefox-${browser_revs.firefox}/firefox | ||||||||||||||||||||||||||
| mkdir -p $firefoxoutdir | ||||||||||||||||||||||||||
| cp -r ${upstream_firefox}/* $firefoxoutdir/ | ||||||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should think about symlinks or xorg.lndir |
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # patchelf the binary | ||||||||||||||||||||||||||
| wrapper="${firefox-bin}/bin/firefox" | ||||||||||||||||||||||||||
| binary="$(readlink -f $(<"$wrapper" grep '^exec ' | grep -o -P '/nix/store/[^"]+' | head -n 1))" | ||||||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is at a fixed location? Or can we get that from the firefox attr via passthru? |
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| interpreter="$(patchelf --print-interpreter "$binary")" | ||||||||||||||||||||||||||
| rpath="$(patchelf --print-rpath "$binary")" | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| find $firefoxoutdir/ -executable -type f | while read i; do | ||||||||||||||||||||||||||
| chmod u+w "$i" | ||||||||||||||||||||||||||
| [[ $i == *.so ]] || patchelf --set-interpreter "$interpreter" "$i" | ||||||||||||||||||||||||||
| patchelf --set-rpath "$rpath" "$i" | ||||||||||||||||||||||||||
|
Comment on lines
+170
to
+176
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||
| chmod u-w "$i" | ||||||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
fixed by nix |
||||||||||||||||||||||||||
| done | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # create the wrapper script | ||||||||||||||||||||||||||
| rm $firefoxoutdir/firefox | ||||||||||||||||||||||||||
| <"$wrapper" grep -vE '^exec ' > $firefoxoutdir/firefox | ||||||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure what this line does |
||||||||||||||||||||||||||
| echo "exec \"$firefoxoutdir/firefox-bin\" \"\$@\"" >> $firefoxoutdir/firefox | ||||||||||||||||||||||||||
| chmod a+x $firefoxoutdir/firefox | ||||||||||||||||||||||||||
|
Comment on lines
+183
to
+184
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can't use wrapProgram? |
||||||||||||||||||||||||||
| '' + '' | ||||||||||||||||||||||||||
| FFMPEG_REVISION=$(jq -r '.browsers[] | select(.name == "ffmpeg").revision' $BROWSERS_JSON) | ||||||||||||||||||||||||||
| mkdir -p $out/ffmpeg-$FFMPEG_REVISION | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
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.