57 lines
2 KiB
Nix
57 lines
2 KiB
Nix
|
final: prev: {
|
||
|
element-desktop = prev.element-desktop.overrideAttrs (oldAttrs: rec {
|
||
|
|
||
|
installPhase =
|
||
|
let
|
||
|
libPath = prev.lib.makeLibraryPath [
|
||
|
prev.libnotify
|
||
|
];
|
||
|
executableName = "element-desktop";
|
||
|
desktopItem = prev.makeDesktopItem {
|
||
|
name = "element-desktop";
|
||
|
exec = "${executableName} %u";
|
||
|
icon = "element";
|
||
|
desktopName = "Element";
|
||
|
genericName = "Matrix Client";
|
||
|
comment = oldAttrs.meta.description;
|
||
|
categories = [ "Network" "InstantMessaging" "Chat" ];
|
||
|
startupWMClass = "element";
|
||
|
mimeTypes = [ "x-scheme-handler/element" ];
|
||
|
};
|
||
|
in
|
||
|
''
|
||
|
runHook preInstall
|
||
|
|
||
|
# resources
|
||
|
mkdir -p "$out/share/element"
|
||
|
ln -s '${prev.element-web}' "$out/share/element/webapp"
|
||
|
cp -r '.' "$out/share/element/electron"
|
||
|
cp -r './res/img' "$out/share/element"
|
||
|
rm -rf "$out/share/element/electron/node_modules"
|
||
|
cp -r './node_modules' "$out/share/element/electron"
|
||
|
cp $out/share/element/electron/lib/i18n/strings/en_EN.json $out/share/element/electron/lib/i18n/strings/en-us.json
|
||
|
ln -s $out/share/element/electron/lib/i18n/strings/en{-us,}.json
|
||
|
|
||
|
# icons
|
||
|
for icon in $out/share/element/electron/build/icons/*.png; do
|
||
|
mkdir -p "$out/share/icons/hicolor/$(basename $icon .png)/apps"
|
||
|
ln -s "$icon" "$out/share/icons/hicolor/$(basename $icon .png)/apps/element.png"
|
||
|
done
|
||
|
|
||
|
# desktop item
|
||
|
mkdir -p "$out/share"
|
||
|
ln -s "${desktopItem}/share/applications" "$out/share/applications"
|
||
|
|
||
|
# executable wrapper
|
||
|
# LD_PRELOAD workaround for sqlcipher not found: https://github.com/matrix-org/seshat/issues/102
|
||
|
makeWrapper '${prev.electron}/bin/electron' "$out/bin/element-desktop" \
|
||
|
--set LD_PRELOAD ${prev.sqlcipher}/lib/libsqlcipher.so \
|
||
|
--set LD_LIBRARY_PATH "${libPath}" \
|
||
|
--add-flags "$out/share/element/electron" \
|
||
|
--add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WebRTCPipeWireCapturer,WaylandWindowDecorations}}"
|
||
|
|
||
|
runHook postInstall
|
||
|
'';
|
||
|
});
|
||
|
}
|