Skip to content
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

session-desktop: fix wayland flags in package #245947

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
{ lib
, makeDesktopItem
, copyDesktopItems
, stdenvNoCC
, fetchurl
, appimageTools
, makeWrapper
}:

let
version = "1.11.0";
pname = "session-desktop";
Expand All @@ -18,39 +15,32 @@ let
appimage = appimageTools.wrapType2 {
inherit version pname src;
};
appimage-contents = appimageTools.extractType2 {
appimageContents = appimageTools.extractType2 {
inherit version pname src;
};
in
stdenvNoCC.mkDerivation {
inherit version pname;
src = appimage;

nativeBuildInputs = [ copyDesktopItems makeWrapper ];

desktopItems = [
(makeDesktopItem {
name = "Session";
desktopName = "Session";
comment = "Onion routing based messenger";
exec = "${appimage}/bin/session-desktop-${version}";
icon = "${appimage-contents}/session-desktop.png";
terminal = false;
type = "Application";
categories = [ "Network" ];
})
];
nativeBuildInputs = [ makeWrapper ];

installPhase = ''
runHook preInstall

mv bin/session-desktop-${version} bin/session-desktop
mv bin/${pname}-${version} bin/${pname}

mkdir -p $out/
cp -r bin $out/bin

wrapProgram $out/bin/session-desktop \
--add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations}}"
mkdir -p $out/share/${pname}
cp -a ${appimageContents}/usr/share/icons $out/share/
install -Dm 644 ${appimageContents}/${pname}.desktop -t $out/share/applications/

substituteInPlace $out/share/applications/${pname}.desktop --replace "AppRun" "${pname}"
Comment on lines +38 to +40
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I woud like to keep the old desktop item as it feels more declarative and uses the full path. Compared to the upstream item that relies on the environment.

However I think it is a good idea to use the icons directly from the upstream and it would be nice if you could make that work with the current desktop item :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Part of the problem was that the desktop file referenced the application directly without the Wayland flags. I'll look into making the desktop file work with the wrapper, but since the flags rely on Bash variable expansion to function, I can't just embed the flag code in the desktop file.

Additionally, I do not think it's possible for the package to reference itself (correct me if I'm wrong) for the desktop file to refer to the wrapper script.

Finally, I think it's fine for the desktop file to only work if the package is installed into the path. To keep the scripts simple, I think it's fine to assume that the .desktop file will only be used if the package is in the path.


wrapProgram $out/bin/${pname} \
--add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform=wayland --enable-features=WaylandWindowDecorations,UseOzonePlatform}}"
Comment on lines +42 to +43
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and the old one ran fine for me on wayland, so lgtm

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like ozone-platform-hint was only added to Electron versions 18+ (and not on version 17.4.10 which is what Session is using (shame))

electron/electron#34937

I could not get native Wayland to work with the hint flag, but it works with the explicit flag. I wonder what your environment is doing that causes this to happen.


runHook postInstall
'';
Expand Down