{"id":24443618,"url":"https://github.com/endlessm/flatpak-bundler","last_synced_at":"2025-04-12T21:26:58.563Z","repository":{"id":57238054,"uuid":"68857285","full_name":"endlessm/flatpak-bundler","owner":"endlessm","description":"Node module for creating flatpaks.","archived":false,"fork":false,"pushed_at":"2020-06-04T22:39:07.000Z","size":40,"stargazers_count":11,"open_issues_count":2,"forks_count":10,"subscribers_count":25,"default_branch":"master","last_synced_at":"2025-03-26T15:42:51.203Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/endlessm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-09-21T21:02:10.000Z","updated_at":"2023-10-17T23:09:49.000Z","dependencies_parsed_at":"2022-08-26T14:04:29.769Z","dependency_job_id":null,"html_url":"https://github.com/endlessm/flatpak-bundler","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/endlessm%2Fflatpak-bundler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/endlessm%2Fflatpak-bundler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/endlessm%2Fflatpak-bundler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/endlessm%2Fflatpak-bundler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/endlessm","download_url":"https://codeload.github.com/endlessm/flatpak-bundler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248317732,"owners_count":21083528,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-20T22:16:53.943Z","updated_at":"2025-04-12T21:26:58.536Z","avatar_url":"https://github.com/endlessm.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# flatpak-bundler [![Version](https://img.shields.io/npm/v/flatpak-bundler.svg)](https://www.npmjs.com/package/flatpak-bundler) [![Build Status](https://img.shields.io/travis/endlessm/flatpak-bundler/master.svg)](http://travis-ci.org/endlessm/flatpak-bundler)\nBuild [flatpaks](http://flatpak.org/) from nodejs.\n\n# Quick Start\n\nInstall flatpak-bundler.\n```shell\n$ npm install flatpak-bundler -g\n```\n\n[Build a flatpak with a node script](#hello-world).\n\nInstall and run it!\n```shell\n$ flatpak install --user --bundle hello.flatpak\n$ flatpak run org.world.Hello\nHello, world!\n```\n\n## Overview\nThis modules allows building flatpaks programatically from node. It requires\nflatpak \u003e= 0.6.13 to be installed on your system.\n\nUnder the hood, this is just a wrapper for the [flatpak-builder](http://flatpak.org/flatpak/flatpak-docs.html#flatpak-builder)\ntool with some extra sugar added.\n\nWith `flatpak-builder` you specify a runtime, sandbox permissions and software\nmodules to build into you application, and build a flatpak from start to finish.\nThis module provides a few additional features:\n\n - Supports auto installing flatpak runtime and app dependencies\n - Supports exporting directly to the a single file flatpak bundle\n - Supports easy copying files and creating symlinks directly in `/app`\n\nThe latter is particularly useful for [electron](http://electron.atom.io/) and\n[nw.js](http://nwjs.io/) style node applications, which often create packages\nfrom prebuilt binaries and do not attempt to follow an autotools-like\n[build api](https://github.com/cgwalters/build-api).\n\nThis module should make it easy to plug flatpak support into a electron or nw.js\napp packaging phase.\n\n## Usage\n\n### bundle(manifest, buildOptions, callback)\n\n`flatpak-bundler` provides a single method, `bundle`, which takes an app\nmanifest, a build options object, and a completion callback.\n\nBoth the manifest and options objects support both camelCase and dash-separated\nvariants of any option.\n\nThe callback with be called with `callback(error, finalBuildOptions)` arguments.\nThe finalBuildOptions contains the build options after default values have been\napplied. Useful to read out the workingDir, for example.\n\n### Manifest\nThis matches the format for flatpak-builder app manifests, with a few extra\noptions added and camelCase variants supported. For complete documentation\nof the manifest format read the [flatpak-builder docs](http://flatpak.org/flatpak/flatpak-docs.html#flatpak-builder).\n\n - **id**: Required. The application id.\n - **runtime**: Required. The runtime for your flatpak application.\n - **sdk**: Required. The sdk for your flatpak application.\n - **base**: An app to inherit from. Use the app as a \"base\" for `/app`\n   contents.\n - **finishArgs**: The arguments to pass to `flatpak build-finish`. Use this to\n   add sandbox permissions. See the [Electron app example](#electron-app) for\n   some common app permissions.\n - **modules**: If you need to build other software modules into you flatpak app\n   (anything not already in your runtime or base app), you can specify them\n   here.\n\nIn addition to standard manifest options, the following extra options are\nsupported.\n - **files**: Files to copy directly into the app. Should be a list of [source,\n   dest] tuples. Source should be a relative/absolute path to a file/directory\n   to copy into the flatpak, and dest should be the path inside the app install\n   prefix (e.g. `/share/applications/`)\n - **symlinks**: Symlinks to create in the app files. Should be a list of\n   [target, location] symlink tuples. Target can be either a relative or\n   absolute path inside the app install prefix, and location should be a\n   absolute path inside the prefix to create the symlink at.\n - **extraExports**: Files to export outside of the flatpak sandbox, in addition\n   to the application desktop file, icons and appstream. File basename *must*\n   be prefixed with the app id. Should not be needed for common use.\n - **runtimeFlatpakref**: A pathname or url to a flatpakref file to use to auto\n   install the runtime.\n - **sdkFlatpakref**: A pathname or url to a flatpakref file to use to auto\n   install the sdk.\n - **baseFlatpakref**: A pathname or url to a flatpakref file to use to auto\n   install the base app.\n\n### Build Options\n - **bundlePath**: Output location for a single file version of the flatpak. If\n   non supplied, the single file flatpak will not be created.\n - **arch**: The architecture for the flatpak bundle. x86_64, i386 or arm.\n - **workingDir**: The working directory to call `flatpak-builder` from.\n   Defaults to a new tmp directory.\n - **buildDir**: The directory to build the application in. Defaults to\n   `${workingDir}/build`\n - **repoDir**: The directory for a flatpak repo, can be used to publish to an\n   existing repo. Defaults to `${workingDir}/repo`\n - **cleanTmpdirs**: Cleanup any tmp directories created during the build on\n   process exit. Defaults to true. Set false for easier debugging.\n - **autoInstallRuntime**: Install/update the runtime while building. Defaults\n   to true if runtimeFlatpakref is set in the manifest.\n - **autoInstallSdk**: Install/update the sdk while building. Defaults\n   to true if sdkFlatpakref is set in the manifest.\n - **autoInstallBase**: Install/update the base app while building. Defaults\n   to true if baseFlatpakref is set in the manifest.\n - **gpgSign**: The gpg key to use to sign the flatpak repo and bundle file.\n - **gpgHomedir**: The gpg homedir to use when signing.\n - **subject**: The single line subject to use for the flatpak repo commit\n   message.\n - **body**: The description to use for the flatpak repo commit message.\n - **bundleRepoUrl**: Repo url for the single file bundle. Installing the bundle\n   will automatically configure a remote for this URL.\n - **extraFlatpakBuilderArgs**: List of extra arguments to pass to the\n   [flatpak-builder](http://flatpak.org/flatpak/flatpak-docs.html#flatpak-builder) command.\n - **extraFlatpakBuildExportArgs**: List of extra arguments to pass to the\n   [flatpak build-export](http://flatpak.org/flatpak/flatpak-docs.html#flatpak-build-export) command.\n - **extraFlatpakBuildBundleArgs**: List of extra arguments to pass to the\n   [flatpak build-bundle](http://flatpak.org/flatpak/flatpak-docs.html#flatpak-build-bundle) command.\n\n### Logging\nTo turn on debugging output set the DEBUG environment variable\n```\nDEBUG=flatpak-bundler npm run my-flatpak-command\n```\n\n## Examples\n\n#### Hello world\n\n```js\n// Write a hello world script to disk\nconst fs = require('fs')\nfs.writeFileSync('hello',\n`#!/bin/bash\necho \"Hello, world!\"`, { mode: 0o755 })\n\n// Make a flapak with it!\nconst flatpakBundler = require('flatpak-bundler')\nflatpakBundler.bundle({\n  id: 'org.world.Hello',\n  runtime: 'org.freedesktop.Platform',\n  runtimeVersion: '1.4',\n  runtimeFlatpakref: 'https://raw.githubusercontent.com/endlessm/flatpak-bundler/master/refs/freedesktop-runtime-1.4.flatpakref',\n  sdk: 'org.freedesktop.Sdk',\n  files: [\n    ['hello', '/bin/hello']\n  ]\n}, {\n  bundlePath: 'hello.flatpak'\n}, function (error) {\n  if (error) {\n    console.error('Error building flatpak', error)\n    return\n  }\n  console.log('Flatpak built successfully')\n})\n```\n\n#### Electron app\n\n```js\nconst flatpakBundler = require('flatpak-bundler')\n\nflatpakBundler.bundle({ // Manifest\n  id: 'org.world.Hello',\n  base: 'io.atom.electron.BaseApp', // Electron base application\n  baseFlatpakref: 'https://s3-us-west-2.amazonaws.com/electron-flatpak.endlessm.com/electron-base-app-master.flatpakref', // So we can auto install the runtime\n  runtime: 'org.freedesktop.Platform', // Use the freedesktop runtime\n  runtimeVersion: '1.4',\n  runtimeFlatpakref: 'https://raw.githubusercontent.com/endlessm/flatpak-bundler/master/refs/freedesktop-runtime-1.4.flatpakref',\n  sdk: 'org.freedesktop.Sdk',\n  files: [\n    [ 'static/linux', '/share/' ], // Desktop file and icons\n    [ packagedFileDir, '/share/bar' ] // Application binaries and assets\n  ],\n  symlinks: [\n    [ '/share/bar/Bar', '/bin/Bar' ] // Create a symlink in /bin to to app executable\n  ],\n  finishArgs: [\n    '--share=ipc', '--socket=x11', // Allow app to show windows with X11\n    '--socket=pulseaudio', // Allow audio output\n    '--filesystem=home', // Allow access to users home directory\n    '--share=network', // Allow network access\n    '--device=dri' // Allow OpenGL rendering\n  ],\n  renameDesktopFile: 'hello.desktop', // Rename the desktop file to agree with the app id so flatpak will export it\n  renameIcon: 'hello' // Rename the icon to agree with the app id so flatpak will export it\n}, { // Build options\n  arch: 'x86_64',\n  bundlePath: 'dist/hello_x86_64.flatpak',\n  gpgSign: '1234ABCD' // Gpg key to sign with\n}, function (error, finalAppOptions, finalBuildOptions) { // Callback\n  if (error) {\n    console.error('Error building flatpak')\n    console.error(error)\n    return\n  }\n  console.log('Flatpak built successfully.')\n  console.log('Build dir and repo in ' + finalBuildOptions.workingDir)\n})\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fendlessm%2Fflatpak-bundler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fendlessm%2Fflatpak-bundler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fendlessm%2Fflatpak-bundler/lists"}