Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions .github/workflows/node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@ jobs:
fail-fast: false
matrix:
python-version:
- '3.9'
- '3.10'
- '3.11'
- '3.12'
- '3.13'
- '3.14'
runs-on: ubuntu-latest
steps:
# 4.2.2
Expand Down Expand Up @@ -57,9 +55,7 @@ jobs:
run: |
flatpak --user remote-add flathub https://flathub.org/repo/flathub.flatpakrepo
flatpak --user install -y flathub \
org.freedesktop.{Platform,Sdk{,.Extension.node{14,16,18}}}//22.08
flatpak --user install -y flathub \
org.freedesktop.{Platform,Sdk{,.Extension.node{20,22}}}//24.08
org.freedesktop.{Platform,Sdk{,.Extension.node{20,22,24}}}//25.08

- name: Install dependencies
run: poetry install --with=dev
Expand Down
5 changes: 4 additions & 1 deletion node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ required, however, you can disable it explicitly via `--no-xdg-layout`.
## Requirements

- flatpak-builder 1.1.2 or newer
- Python 3.9+.
- Python 3.11+.
- [pipx](https://pypa.github.io/pipx/) (recommended) or
[pip](https://pip.pypa.io/en/stable/) (both of these are usually available in
your distro repositories, the latter is often included with Python installs).
Expand Down Expand Up @@ -40,6 +40,9 @@ There are two examples provided for how to use flatpak-node-generator:
- `webpack-quick-start` - A Flatpak of
[electron-webpack-quick-start](https://github.com/electron-userland/electron-webpack-quick-start).
It uses yarn for package management and electron-builder + webpack.
- `fiddle-yarn-berry` - A Flatpak of
[electron-fiddle](https://github.com/electron/fiddle.git). It uses yarn/berry for
package management and a rather basic Electron workflow.

Both manifests have comments to highlight their differences, so you can mix and match to e.g.
get npm with electron-builder.
Expand Down
3 changes: 3 additions & 0 deletions node/fiddle-yarn-berry/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/yarn.lock
/generated-sources.json
/build
12 changes: 12 additions & 0 deletions node/fiddle-yarn-berry/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# vanilla-quick-start

Showcases building a Flatpak of [electron-fiddle](https://github.com/electron/fiddle.git)

To create generated-sources.json run:

```sh
./gen.sh
```

## Run app in Fiddle
Add `--no-sandbox` to `Prefrences -> Execution -> Electron Flags`
9 changes: 9 additions & 0 deletions node/fiddle-yarn-berry/gen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

dir="$(dirname $(realpath $0))"
commit=98c0605f804df86df8636a477515bbe178cd3943

pushd "$dir/.."
curl -L "https://github.com/electron/fiddle/raw/$commit/yarn.lock" > "$dir/yarn.lock"
poetry run flatpak-node-generator yarn -o "$dir/generated-sources.json" "$dir/yarn.lock"
popd
89 changes: 89 additions & 0 deletions node/fiddle-yarn-berry/org.electronjs.fiddle.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
app-id: org.electronjs.fiddle
runtime: org.freedesktop.Platform
runtime-version: '25.08'
sdk: org.freedesktop.Sdk
# Use the Electron 2 BaseApp, which adds several common libraries we'll need.
base: org.electronjs.Electron2.BaseApp
base-version: '25.08'
separate-locales: false
# Add the Node SDK extension.
sdk-extensions:
- org.freedesktop.Sdk.Extension.node24
command: fiddle
finish-args:
# These three lines add the permissions needed for graphics.
- --device=dri
- --share=ipc
- --socket=x11
- --socket=wayland
# Sound access.
- --socket=pulseaudio
# Network access.
- --share=network
# If you need to access the filesystem, also add:
# - --filesystem=home
modules:
# Now is the quickstart module.
- name: fiddle
buildsystem: simple
build-options:
# Add the node bin directory.
append-path: /usr/lib/sdk/node24/bin
env:
XDG_CACHE_HOME: /run/build/fiddle/flatpak-node/cache
npm_config_nodedir: /usr/lib/sdk/node24
# more verbose
YARN_ENABLE_INLINE_BUILDS: '1'
# disable telemetry
YARN_ENABLE_TELEMETRY: '0'
# disable network access
YARN_ENABLE_NETWORK: '0'
# disable global cache
YARN_ENABLE_GLOBAL_CACHE: '0'
# set yarn global folder
YARN_GLOBAL_FOLDER: /run/build/fiddle/flatpak-node/yarn-berry
build-commands:
# print yarn basic info
- yarn config
# setup yarn for flatpak
- yarn plugin import $FLATPAK_BUILDER_BUILDDIR/flatpak-node/flatpak-yarn.js
# prepare yarn cache
- yarn convertToZip $(which yarn)
# Install the packages from our offline cache.
# --prefix= is the path to our subdirectory (see the electron-quick-start source below).
- yarn install

- yarn run package
- mv out/Electron* /app/ElectronFiddle
- install -Dm755 fiddle.sh /app/bin/fiddle
sources:
- type: git
url: https://github.com/electron/fiddle.git
commit: 98c0605f804df86df8636a477515bbe178cd3943

# Add the flatpak-node-generator generated sources.
- generated-sources.json
# Our runner script.
- type: script
dest-filename: fiddle.sh
commands:
# We need to wrap the main binary with Zypak in order for sandboxing
# to work. Without this, we'll get errors about the "SUID sandbox
# helper binary".
- exec zypak-wrapper /app/ElectronFiddle/electron-fiddle

# Sources below are only for fiddle, as it wants to fetch these online
# prefetch for offline
- type: file
url: https://releases.electronjs.org/releases.json
sha256: badb8576b81b4e43716aa3314724c9563d42eb4140cf06000201ad7a31067dc4
# replace to use release.json prefetched
- type: file
path: replace/fetch-releases.ts
dest-filename: fetch-releases.ts
dest: tools
# used embed contributors.json
- type: file
path: replace/contributors.json
dest-filename: contributors.json
dest: static
20 changes: 20 additions & 0 deletions node/fiddle-yarn-berry/replace/contributors.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[
{
"url": "https://github.com/felixrieseberg",
"api": "https://api.github.com/users/felixrieseberg",
"login": "felixrieseberg",
"avatar": "https://avatars.githubusercontent.com/u/1426799?v=4",
"name": "Felix Rieseberg",
"bio": "🙇 ✨🌳 ",
"location": "San Francisco"
},
{
"url": "https://github.com/dsanders11",
"api": "https://api.github.com/users/dsanders11",
"login": "dsanders11",
"avatar": "https://avatars.githubusercontent.com/u/5820654?v=4",
"name": "David Sanders",
"bio": null,
"location": "Santa Barbara, CA"
}
]
22 changes: 22 additions & 0 deletions node/fiddle-yarn-berry/replace/fetch-releases.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import * as fs from 'node:fs';
import * as path from 'node:path';

const outputFile = path.join(__dirname, '..', 'static', 'releases.json');

export async function populateReleases() {
const sourceDir = process.env.FLATPAK_BUILDER_BUILDDIR;

if (!sourceDir) {
throw new Error('FLATPAK_BUILDER_BUILDDIR is not set.');
}

const inputFile = path.resolve(sourceDir, 'releases.json');
const data = await fs.promises.readFile(inputFile, 'utf-8');
await fs.promises.writeFile(outputFile, data);
}

if (require.main === module) {
(async () => {
await populateReleases();
})();
}
Loading