Skip to content

[WIP] nyxt: fix on darwin#125113

Closed
mjlbach wants to merge 2 commits intoNixOS:masterfrom
mjlbach:build_nyxt_darwin
Closed

[WIP] nyxt: fix on darwin#125113
mjlbach wants to merge 2 commits intoNixOS:masterfrom
mjlbach:build_nyxt_darwin

Conversation

@mjlbach
Copy link
Contributor

@mjlbach mjlbach commented May 31, 2021

Motivation for this change

Now that webkitgtk is fixed, trying to get nyxt to build on darwin. Notify-osd is no longer a dependency of nyxt per the 2.0 changelog, so this can be removed from the buildinputs.

The makefile of nyxt includes install-app-bundle as a dependency of the install target, which is what is causing the remaining failure. https://github.com/atlas-engineer/nyxt/blob/23858171e28e06f2841bd06ff22dd30c5e649fe8/Makefile#L53-L55

 nix build '.#nyxt'
error: builder for '/nix/store/qdv3dra27ys8wp40wfy50747vgdf4w98-lisp-nyxt-2.0.0.drv' failed with exit code 2;
       last 10 log lines:
       > writing 27410432 bytes from the immobile space at 0x52000000
       > done]
       > mkdir -p ./Nyxt.app/Contents/MacOS
       > mkdir -p ./Nyxt.app/Contents/Resources
       > mv ./nyxt ./Nyxt.app/Contents/MacOS
       > cp ./assets/Info.plist ./Nyxt.app/Contents
       > cp ./assets/nyxt.icns ./Nyxt.app/Contents/Resources
       > cp -r Nyxt.app /Applications
       > cp: cannot create directory '/Applications/Nyxt.app': Permission denied
       > make: *** [Makefile:55: install-app-bundle] Error 1
       For full logs, run 'nix log /nix/store/qdv3dra27ys8wp40wfy50747vgdf4w98-lisp-nyxt-2.0.0.drv'.
error: 1 dependencies of derivation '/nix/store/hlrplm1hrn2xq7f7zxfl3kakz9anlh58-nyxt-2.0.0.drv' failed to build

I don't actually know where make install is called in the darwin builder, so any advice on fixing this last hurdle is appreciated!

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Added a release notes entry if the change is major or breaking
  • Fits CONTRIBUTING.md.

@ofborg ofborg bot added the 6.topic: darwin Running or building packages on Darwin label May 31, 2021
@ofborg ofborg bot requested a review from nlewo May 31, 2021 18:22
@ofborg ofborg bot added 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux. labels May 31, 2021
@happysalada
Copy link
Contributor

happysalada commented Jun 1, 2021

I've tried on my machine and I get another failure

/nix/store/sv61k1l9fapkn1dzlvclqjl5i1sbhfyw-stdenv-darwin/setup: line 1397: /nix/store/vbyx1hhgfai7jb39l6jhvdj5zimkjzhy-gnumake-4.3/bin/make: Argument list too long

I'm going to try again enabling debug, to see if I get more info

@mjlbach mjlbach force-pushed the build_nyxt_darwin branch from 495cae0 to c4d8032 Compare June 1, 2021 16:48
@midchildan
Copy link
Member

I got a derivation here that now manages to build and launch, but the resulting binary is slow and buggy with critical features like key input not working. My suspicion is that Nyxt currently only works with the XQuartz GTK backend, and it needs some fixing before it can work with the native Quartz backend.

@mjlbach
Copy link
Contributor Author

mjlbach commented Jun 1, 2021

Yes same (currently the derivation builds for me too with this PR, it's just also extremely slow)

@midchildan
Copy link
Member

Does keyboard input work for you? So far, I'm only able to supply non-alphanumerical input.

@mjlbach
Copy link
Contributor Author

mjlbach commented Jun 1, 2021

Yes, if I hold down cmd

@midchildan
Copy link
Member

After further debugging, it seems likely that the keyboard input problem is caused by Nyxt itself. I traced the on-signal-key-press-event function, and it seems GTK is passing the key press event correctly.

Here's the result of pressing "a" in a Nyxt window:

0: (NYXT::ON-SIGNAL-KEY-PRESS-EVENT #<NYXT:USER-WINDOW {10033BF663}> #S(GDK:GDK-EVENT-KEY :TYPE :KEY-PRESS :WINDOW #<GDK:GDK-WINDOW {100A39BF83}> :SEND-EVENT NIL :TIME 57662196 :STATE NIL :KEYVAL 97 :LENGTH 1 :STRING "a" :HARDWARE-KEYCODE 0 :GROUP 0 :IS-MODIFIER 0))
  0: NYXT::ON-SIGNAL-KEY-PRESS-EVENT returned NIL

Looking around the code, there seems to be some Darwin-specific workaround for key handling, so that looks kind of suspicious:
https://github.com/atlas-engineer/nyxt/blob/f1b697476bf92816ba1050812f63981a62497e82/source/renderer-gtk.lisp#L11-L19

@jmercouris
Copy link

The work around was due to modifiers being incorrectly handled on macOS. I could not reliably query GTK for the active modifiers. Instead, I had to capture them at keypress time and manually toggle them on/off.

With regards to Quartz being a problem, I was able to run directly in Quartz without using XQuartz (though I did notice some strange problems). If you can, I strongly suggest attempting to use the GK-GTK renderer instead of just the GTK version as provided in this PR. It may fix many of your issues.

@mjlbach
Copy link
Contributor Author

mjlbach commented Jun 5, 2021

is the GK-GTK renderer just a flag we can enable? I'll look into it :)

@jmercouris
Copy link

GI-GTK is a flag in the makefile

@midchildan
Copy link
Member

@jmercouris Thanks for looking into this. I've enabled the GI-GTK renderer in my branch, but the problem still remains. Judging from the debug logs, the key inputs seem to be forwarded to webkit-gtk, so I'm now attempting to get debug logs out of WebKit.

WARNING:
   Type initializer for class 'GdkX11DeviceXI2' (GType 'GDK-X11-DEVICE-XI2') is invalid: foreign symbol 'gdk_x11_device_xi2_get_type'
WARNING:
   Type initializer for class 'GdkX11DeviceManagerCore' (GType 'GDK-X11-DEVICE-MANAGER-CORE') is invalid: foreign symbol 'gdk_x11_device_manager_core_get_type'
WARNING:
   Type initializer for class 'GdkX11DeviceManagerXI2' (GType 'GDK-X11-DEVICE-MANAGER-XI2') is invalid: foreign symbol 'gdk_x11_device_manager_xi2_get_type'
WARNING:
   Type initializer for class 'GtkPlug' (GType 'GTK-PLUG') is invalid: foreign symbol 'gtk_plug_get_type'
WARNING:
   Type initializer for class 'GtkSocket' (GType 'GTK-SOCKET') is invalid: foreign symbol 'gtk_socket_get_type'
<INFO> [18:42:57] Listening to socket "nyxt/nyxt.socket".
Nyxt version 2.0.0
<INFO> [18:42:57] Loading Lisp file "/Users/midchildan/.config/nyxt/auto-config.lisp".
<DEBUG> [18:42:57] Lisp file "/Users/midchildan/.config/nyxt/init.lisp" does not exist.
<DEBUG> [18:42:57] Initializing GI-GTK Interface
<DEBUG> [18:43:18] BASE-MODE enabled.
<DEBUG> [18:43:18] WEB-MODE enabled.
<DEBUG> [18:43:18] VI-NORMAL-MODE enabled.
<DEBUG> [18:43:18] HELP-MODE enabled.
<DEBUG> [18:43:18] VI-NORMAL-MODE enabled.
<DEBUG> [18:43:18] PROMPT-BUFFER-MODE enabled.
Fontconfig error: Fontconfig error: Cannot load default config fileCannot load default config file

Fontconfig error: Cannot load default config file
Fontconfig error: Cannot load default config file
<DEBUG> [18:43:24] Found key binding "button1" to VI-BUTTON1
<WARN> [18:43:24] Warning: Error on GTK thead: NIL fell through ETYPECASE expression.
                    Wanted one of (GDK:GDK-EVENT-BUTTON GDK:GDK-EVENT-KEY
                                   GDK:GDK-EVENT-SCROLL).
<DEBUG> [18:43:25] NYXT::KEY-STRING: "a" NYXT::KEYCODE: 0 CHARACTER: #\a NYXT::KEYVAL-NAME: "a"
<DEBUG> [18:43:25] Fallback forward key "\"a\""
<INFO> [18:43:26] Deleting socket "nyxt/nyxt.socket".

I've also created a fix for the GI-GTK renderer in atlas-engineer/nyxt#1476 to fix a Darwin crash.

@mjlbach
Copy link
Contributor Author

mjlbach commented Jun 6, 2021

@midchildan would you like to open a PR and continue discussions there? Otherwise I'll integrate the changes in this PR.

@midchildan midchildan mentioned this pull request Jun 7, 2021
11 tasks
@midchildan
Copy link
Member

@mjlbach I have some few additional fixes, so I created a new PR in #126082. The problem with ignored keypresses still remains, but it turned out to be a problem with the WebKitGTK package, so it deserves a separate issue. Since critical issues in the Nyxt package has now been addressed, I believe this is now ready for review. Could you please take look?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: darwin Running or building packages on Darwin 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants