wayland: enable ozone via $NIXOS_OZONE_WL#147557
Conversation
|
do you miss |
5727342 to
51b27bd
Compare
Ah, added it now (but did not test)
Hmm that's a good idea, we can do that too. It would mean adding a --run to makeWrapper that sources a generic electron-loading script that defines extra flags. However, instead of putting a single simple env var, users would have to put a complex line in all those config files. We could have a generic fallback config, but still. |
pkgs/top-level/all-packages.nix
Outdated
There was a problem hiding this comment.
I think we should add aliases for those.
There was a problem hiding this comment.
If it hasn't been in a stable release then it doesn't need an alias so check that first
There was a problem hiding this comment.
Well we probably can't avoid it getting released with 21.11 so that will be a stable release.
The alias should just be a wrapper that sets the environment variable, no biggie.
|
(Coming from #147945) |
Isn't this PR exactly that? |
|
Bad wording on my part, it doesn't require the separate packages anymore, but you still need to do more than to install chrom*. It would be nice to just start chrom* with Wayland support without breaking Xorg support, I currently have no Xorg setup, so that is why I asked that "dumb" question. |
|
@TilCreator ah - what you need to do is ensure that NIXOS_OZONE=y is in your environment. The reason for that is that ozone support is still not 100% so unless you choose it explicitly, we shouldn't force it for everyone. |
|
Ah, explicitly enabling it then should be needed. I would prefer this then over #147945 |
|
I'm wondering if I should make this slightly more complex, and make all Cr* projects add a It would allow more complex rules but OTOH it's more magic. |
|
This should also be enabled for discord/discord-ptb/discord-canary. |
|
added discord and the wrapper scripts for the 2 *-wayland packages I think this is good to merge and backport to 21.11. For the wrapping, it would be nice if there was a less error-prone way of providing the makeWrapper arguments. Perhaps a |
|
so - anyone opposed to merging this? |
|
I'm trying to adapt diff --git a/nixos/tests/vscodium.nix b/nixos/tests/vscodium.nix
index 43a0d61c856..f10effe2790 100644
--- a/nixos/tests/vscodium.nix
+++ b/nixos/tests/vscodium.nix
@@ -4,11 +4,17 @@ let
imports = [ ./common/wayland-cage.nix ];
services.cage.program = ''
- ${pkgs.vscodium}/bin/codium \
- --enable-features=UseOzonePlatform \
- --ozone-platform=wayland
+ ${pkgs.vscodium}/bin/codium
'';
+ environment.variables.NIXOS_OZONE = "y";
+
+ nixpkgs.overlays = [
+ (self: super: {
+ cage = super.cage.override { xwayland = null; };
+ })
+ ];
+
fonts.fonts = with pkgs; [ dejavu_fonts ];
};
xorg = { pkgs, ... }: {Any idea what could be going on here? |
|
@Synthetica9 thanks for checking that! Are you sure the test doesn't just dump core without the change? Could you add a I must say I'm mystified how this could cause a coredump, it should be the exact same behavior :-/ |
Yep, when I just run it unmodified (or with only the overlay) it works on this PR. I'm also quite flabbergasted on the how and why of this crash tbh |
|
@Synthetica9 can you change the program to |
Sure, that's a possibility, but then again it'd also be surprising if those Electron apps would still work on modern Wayland compositors. They won't work with wlroots 0.15 (https://bugs.chromium.org/p/chromium/issues/detail?id=1279574), other compositors will follow soon, and for such old Ozone/Wayland revisions there could be additional incompatibilities. |
|
It feels like |
I just tested VS Code and it requires both flags to render with Wayland natively and it seems to work fine without crashing. |
Chrome, Chromium, VSCode, Slack, Signal, Discord, element-desktop, schildichat. For the latter two, the feature flag useWayland was removed and a wrapper script was provided.
|
Ok I renamed the flag to NIXOS_OZONE_WL=1 to keep it a little shorter. Good to go? |
primeos
left a comment
There was a problem hiding this comment.
Ok I renamed the flag to NIXOS_OZONE_WL=1 to keep it a little shorter.
Not sure if that's a good idea but it shouldn't really matter anyway so ¯_(ツ)_/¯
From a quick glance the diff looks ok (I haven't done any testing though).
And this is certainly much better than adding separate -wayland packages :)
@Enzime and thanks for testing if --enable-features=UseOzonePlatform is required. Seems like I was wrong and that change is still too recent.
|
@primeos there is a test and it passes, so merging. In case of trouble we can still revert :) |
|
@wmertens ok, thanks for your work and seeing this through! :) |
|
This doesn't work as intended. This syntax: --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--enable-features=UseOzonePlatform --ozone-platform=wayland}}"checks the variables are set at build time not runtime. You can see this behavior if you run the build manually: $ cd $(mktemp -d)
$ nix-shell '<nixpkgs>' -A chromium --pure --run 'source $stdenv/setup; out=. sandbox=./sandbox NIXOS_OZONE_WL=1 WAYLAND_DISPLAY=1 genericBuild'
Builder called die: makeWrapper doesn't understand the arg --ozone-platform=waylandAnd if those env vars are not set at build time (which they probably never would be), nothing gets appended. I believe this needs to use the double-escaping used elsewhere: in order to have a chance to work, that is. EDIT: most of the above is wrong in the general case, it turns out that double-escaping is only needed for |
|
Odd, I did test it. I'll investigate. |
|
Oh, right, strange... Back then I didn't find an elegant solution due to the way There's hopefully a better alternative available. |
|
@eddyb are you seeing it not work somewhere? It's working correctly for me with vscode and google-chrome-stable. |
|
Ah, interesting, I've only tested it with Chromium but e.g. Signal-Desktop works: $ git rev-parse HEAD
5bb20f9dc70e9ee16e21cc404b6508654931ce41
$ tail -n1 $(nix-build -A chromium)/bin/chromium
gq7rrhd10df-chromium-unwrapped-97.0.4692.99/libexec/chromium/chromium" "$@"
$ tail -n1 $(nix-build -A signal-desktop)/bin/signal-desktop
exec -a "$0" "/nix/store/k7cjv6sg0pqqrdqlm6abv6vyxw9kgp49-signal-desktop-5.29.1/bin/.signal-desktop-wrapped" ${NIXOS_OZONE_WL:+${WAYLAND_DISPLAY:+--enable-features=UseOzonePlatform --ozone-platform=wayland}} "$@"Looks like it works via diff --git a/pkgs/applications/networking/browsers/google-chrome/default.nix b/pkgs/applications/networking/browsers/google-chrome/default.nix
index e93ea8ca66d..b0fc87a1801 100644
--- a/pkgs/applications/networking/browsers/google-chrome/default.nix
+++ b/pkgs/applications/networking/browsers/google-chrome/default.nix
@@ -142,8 +142,9 @@ in stdenv.mkDerivation {
makeWrapper "$out/share/google/$appname/google-$appname" "$exe" \
--prefix LD_LIBRARY_PATH : "$rpath" \
--prefix PATH : "$binpath" \
- --prefix XDG_DATA_DIRS : "$XDG_ICON_DIRS:$GSETTINGS_SCHEMAS_PATH:${addOpenGLRunpath.driverLink}/share" \
- --add-flags ${escapeShellArg commandLineArgs}
+ --prefix XDG_DATA_DIRS : "$XDG_ICON_DIRS:$GSETTINGS_SCHEMAS_PATH" \
+ --add-flags ${escapeShellArg commandLineArgs} \
+ --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--enable-features=UseOzonePlatform --ozone-platform=wayland}}"
for elf in $out/share/google/$appname/{chrome,chrome-sandbox,${crashpadHandlerBinary},nacl_helper}; do
patchelf --set-rpath $rpath $elf
diff --git a/pkgs/applications/networking/instant-messengers/signal-desktop/default.nix b/pkgs/applications/networking/instant-messengers/signal-desktop/default.nix
index f1bcd101279..22440d71805 100644
--- a/pkgs/applications/networking/instant-messengers/signal-desktop/default.nix
+++ b/pkgs/applications/networking/instant-messengers/signal-desktop/default.nix
@@ -123,6 +123,7 @@ in stdenv.mkDerivation rec {
gappsWrapperArgs+=(
--prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath [ stdenv.cc.cc ] }"
${customLanguageWrapperArgs}
+ --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--enable-features=UseOzonePlatform --ozone-platform=wayland}}"
)
# Fix the desktop linkSeems like I also missed that you've dropped |
I was testing with the EDIT: okay, yeah, rereading the comment above, |
There was a problem hiding this comment.
Looks like 6/8 are likely broken (left comments), only Signal and VSCode (the main ones mentioned being tested) seem to be correct.
EDIT: I was wrong, see #147557 (comment)
| "''${gappsWrapperArgs[@]}" \ | ||
| --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--enable-features=UseOzonePlatform --ozone-platform=wayland}}" \ |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
There was a problem hiding this comment.
Unfortunately wrapGAppsHook is AFAIK (and I lack knowledge in that area) only intended for GNOME applications (does a lot more). But I think it's often also used for GTK applications in general so that's probably why it's used for some Electron apps. It'd probably be a good idea to investigate if it's usage is appropriate for Chromium/Electron or not and use a consistent approach - but that deserves a dedicated issue.
Anyway, the implementation, for reference:
| eval makeWrapper "${browserBinary}" "$out/bin/chromium" \ | ||
| --add-flags ${escapeShellArg (escapeShellArg commandLineArgs)} | ||
| --add-flags ${escapeShellArg (escapeShellArg commandLineArgs)} \ | ||
| --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--enable-features=UseOzonePlatform --ozone-platform=wayland}}" |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
There was a problem hiding this comment.
We shouldn't use commandLineArgs itself as that isn't extendable (we could only set a default which is probably not how it should be - also has some advantages though) but we could use the same escapeShellArg based approach.
| makeWrapper "$out/share/google/$appname/google-$appname" "$exe" \ | ||
| --prefix LD_LIBRARY_PATH : "$rpath" \ | ||
| --prefix PATH : "$binpath" \ | ||
| --prefix XDG_DATA_DIRS : "$XDG_ICON_DIRS:$GSETTINGS_SCHEMAS_PATH:${addOpenGLRunpath.driverLink}/share" \ | ||
| --add-flags ${escapeShellArg commandLineArgs} | ||
| --prefix XDG_DATA_DIRS : "$XDG_ICON_DIRS:$GSETTINGS_SCHEMAS_PATH" \ | ||
| --add-flags ${escapeShellArg commandLineArgs} \ | ||
| --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--enable-features=UseOzonePlatform --ozone-platform=wayland}}" |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
There was a problem hiding this comment.
This one is weird, and I guess it might explain why it's not broken (IIUC one of the comments).
It only seems to need escapeShellArg once for commandLineArgs instead of twice, is there a second escaping elsewhere?
The only difference I can see is this is in (EDIT: it was installPhase but chromium is in buildCommand?eval)
|
@wmertens Ugh, sorry for all the noise, it might just be (Frankly the entire EDIT: wait, it's doing |
|
@primeos Regarding reusing let commandLineArgs =
"${commandLineArgs} \${NIXOS_OZONE_WL:+\${WAYLAND_DISPLAY:+--enable-features=UseOzonePlatform --ozone-platform=wayland}}";(i.e. not changing (not sure about the escaping syntax, but at least if it was always done in Nix, it should be possible to remain consistent and avoid weird shell escaping syntax) |
Motivation for this change
Instead of adding separate wayland packages for Electron and Chrome based applications, allow the user to set the environment variable
NIXOS_OZONE=y, which adds the necessary flags at runtime, and only on Wayland.This way, there is no separate wrapper needed and the functionality can be chosen at runtime.
Things done
sandbox = trueset innix.conf? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)nixos/doc/manual/md-to-db.shto update generated release notes