Skip to content

Commit

Permalink
Package electron port as a flatpak.
Browse files Browse the repository at this point in the history
  • Loading branch information
aadcg committed Dec 6, 2024
1 parent 39bfbdf commit 306153c
Show file tree
Hide file tree
Showing 3 changed files with 3,901 additions and 0 deletions.
110 changes: 110 additions & 0 deletions engineer.atlas.Nyxt-Electron.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
app-id: engineer.atlas.Nyxt-Electron
runtime: org.freedesktop.Platform
runtime-version: '24.08'
sdk: org.freedesktop.Sdk
sdk-extensions:
- org.freedesktop.Sdk.Extension.node20
base: org.electronjs.Electron2.BaseApp
base-version: '24.08'
rename-icon: nyxt
rename-appdata-file: nyxt.metainfo.xml
rename-desktop-file: nyxt.desktop
command: nyxt

build-options:
append-path: /usr/lib/sdk/node20/bin

finish-args:
- --device=dri
- --share=network
- --share=ipc
- --socket=wayland
- --socket=fallback-x11
- --socket=pulseaudio
- --socket=cups
- --filesystem=host
# Allow invoking host commands via flatpak-spawn --host <command> <command-args>
- --talk-name=org.freedesktop.Flatpak
# See http://sbcl.org/getting.html
- --env=SBCL_HOME=/app/lib/sbcl

modules:
- name: sbcl
buildsystem: simple
sources:
- type: archive
url: http://prdownloads.sourceforge.net/sbcl/sbcl-2.4.10-x86-64-linux-binary.tar.bz2
sha256: 99cc019120172bb4317f3c79cfc3afffe51e314091e07e8c0ba1d94759767777
only-arches: [x86_64]
build-commands:
- INSTALL_ROOT=${FLATPAK_DEST} sh install.sh

- name: xsel
buildsystem: autotools
sources:
- type: git
url: https://github.com/kfish/xsel.git
tag: 1.2.1

- name: wl-clipboard
buildsystem: meson
config-opts:
- -Dzshcompletiondir=no
- -Dfishcompletiondir=no
sources:
- type: git
url: https://github.com/bugaevc/wl-clipboard.git
tag: v2.2.1

- name: libfixposix
buildsystem: autotools
sources:
- type: git
url: https://github.com/sionescu/libfixposix.git
tag: v0.5.1
- type: script
dest-filename: autogen.sh
commands:
- autoreconf -fi
cleanup:
- /lib/pkgconfig
- /include
- '*.h'
- '*.pc'
- '*.la'

- name: nyxt
buildsystem: simple
build-options:
env:
XDG_CACHE_HOME: /run/build/nyxt/flatpak-node/cache
npm_config_cache: /run/build/nyxt/flatpak-node/npm-cache
npm_config_nodedir: /run/build/nyxt/flatpak-node/cache/node-gyp/32.2.5
build-commands:
# Have node available at runtime
- /usr/lib/sdk/node20/install-sdk.sh
- mkdir -p ${FLATPAK_DEST}/bin
- ln -s ${FLATPAK_DEST}/node/bin/node ${FLATPAK_DEST}/bin/node
- ln -s ${FLATPAK_DEST}/node/bin/npm ${FLATPAK_DEST}/bin/npm

# Install cl-electron-server
- cp _build/cl-electron/package.json _build/cl-electron/package-lock.json _build/cl-electron/source/server.js ${FLATPAK_DEST}
- npm install --offline --verbose --prefix ${FLATPAK_DEST}

# Patch cl-electron
- sed -i "s|(uiop:xdg-runtime-dir \"cl-electron/\")|(uiop:xdg-runtime-dir \"app/$FLATPAK_ID/cl-electron/\")|" _build/cl-electron/source/core.lisp
- sed -i "s|(asdf:system-relative-pathname :cl-electron \"source/server.js\")|#P\"$FLATPAK_DEST/server.js\"|" _build/cl-electron/source/core.lisp
- sed -i "s|(asdf:system-source-directory :cl-electron)|#P\"$FLATPAK_DEST\"|" _build/cl-electron/source/core.lisp
- sed -i "s|(:pathname p :keep t :type \"js\")|(:pathname p :prefix (uiop:xdg-runtime-dir \"app/$FLATPAK_ID/\") :keep t :type \"js\")|" _build/cl-electron/source/core.lisp

# Compile Nyxt
- make install NYXT_RENDERER=electron DESTDIR=${FLATPAK_DEST} PREFIX=

# Fix sandbox
- sed -i "s|\"electron\",|\"zypak-wrapper /app/node_modules/electron/dist/electron\",|" ${FLATPAK_DEST}/package.json
sources:
- type: dir
path: .
# Generated via:
# flatpak-node-generator --electron-node-headers npm _build/cl-electron/package-lock.json
- generated-sources.json
Loading

0 comments on commit 306153c

Please sign in to comment.