build(electron): flatpak support for linux (#8439)

some issues
- app icon not showing correctly
- missing wayland support
- runtime is outdated

related to
- https://github.com/toeverything/AFFiNE/issues/3272
- https://github.com/toeverything/AFFiNE/issues/5985
- https://github.com/toeverything/AFFiNE/issues/6642
This commit is contained in:
pengx17
2024-10-10 09:51:32 +00:00
parent 46321b72ba
commit 06e059db88
5 changed files with 92 additions and 8 deletions

View File

@@ -10,6 +10,7 @@ import {
arch,
buildType,
icnsPath,
iconPngPath,
iconUrl,
iconX64PngPath,
icoPath,
@@ -19,6 +20,8 @@ import {
const fromBuildIdentifier = utils.fromBuildIdentifier;
const linuxMimeTypes = [`x-scheme-handler/${productName.toLowerCase()}`];
const __dirname = fileURLToPath(new URL('.', import.meta.url));
const makers = [
!process.env.SKIP_BUNDLE &&
@@ -96,7 +99,39 @@ const makers = [
name: productName,
productName,
icon: iconX64PngPath,
mimeType: ['x-scheme-handler/affine'],
mimeType: linuxMimeTypes,
},
},
},
!process.env.SKIP_BUNDLE && {
name: '@electron-forge/maker-flatpak',
platforms: ['linux'],
/** @type {import('@electron-forge/maker-flatpak').MakerFlatpakConfig} */
config: {
options: {
mimeType: linuxMimeTypes,
productName,
bin: productName,
id: fromBuildIdentifier(appIdMap),
icon: iconPngPath, // not working yet
branch: buildType,
runtimeVersion: '20.08',
finishArgs: [
// Wayland/X11 Rendering
'--socket=wayland',
'--socket=x11',
'--share=ipc',
// Open GL
'--device=dri',
// Audio output
'--socket=pulseaudio',
// Read/write home directory access
'--filesystem=home',
// Allow communication with network
'--share=network',
// System notifications with libnotify
'--talk-name=org.freedesktop.Notifications',
],
},
},
},

View File

@@ -34,6 +34,7 @@
"@electron-forge/core-utils": "^7.3.0",
"@electron-forge/maker-deb": "^7.5.0",
"@electron-forge/maker-dmg": "^7.3.0",
"@electron-forge/maker-flatpak": "^7.5.0",
"@electron-forge/maker-squirrel": "^7.3.0",
"@electron-forge/maker-zip": "^7.3.0",
"@electron-forge/plugin-auto-unpack-natives": "^7.3.0",