FLATPAK-BUILD(1)
π
FLATPAK-BUILD β the flatpak build page, but make it make sense
okay bestie, welcome to the flatpak build(1) manual, section 1 of the flatpak manual. this is the one that actually runs your build command inside a directory. let's go π
β¨ NAME β¨
flatpak-build β build in a directory. that's it. that's the whole name. short, sweet, iconic. π
π¦ SYNOPSIS π¦
flatpak build [OPTION...] DIRECTORY [COMMAND [ARG...]]
πΈ DESCRIPTION πΈ
so what this does: it runs a build command in a directory. no cap.
and like, DIRECTORY has to have been initialized first with flatpak build-init. you can't just roll up with a random folder, she needs to be prepped. π
here's the cute part, the actual magic: the sdk that's specified in the metadata file inside that directory gets mounted at /usr. and then the files and var subdirectories get mounted at /app and /var, respectively. π«
and the way they're writable, and their contents are preserved between build commands? that's the whole point, bestie β it lets you accumulate build artifacts in there. your progress stays. she remembers. π«Ά
π OPTIONS π
here's everything you can pass. the following options are understood:
-h,--helpβ show help options and dip. exit, periodt. βοΈ-v,--verboseβ print debug information while the command is processing. she's chatty and we love that.--ostree-verboseβ print OSTree debug information during command processing. yes, more. give us more. π₯-r,--runtimeβ use the non-devel runtime that's specified in the application metadata instead of the devel runtime. glow-down mode, but make it intentional.-p,--die-with-parentβ kill the build process and all its children when the launching process dies. dramatic? yes. necessary? also yes. π--bind-mount=DEST=SOURCEβ add a custom bind mount in the build namespace. can be specified multiple times. stack 'em up. π§--build-dir=PATHβ start the build in this directory (the default is in the current directory).--share=SUBSYSTEMβ share a subsystem with the host session. this overrides the Context section from the application metadata.SUBSYSTEMmust be one of:network,ipc. this option can be used multiple times. sharing is caring fr fr.--unshare=SUBSYSTEMβ don't share a subsystem with the host session. this overrides the Context section from the application metadata.SUBSYSTEMmust be one of:network,ipc. this option can be used multiple times. boundaries. we set them. π§--socket=SOCKETβ expose a well-known socket to the application. this overrides to the Context section from the application metadata.SOCKETmust be one of:x11,wayland,fallback-x11,pulseaudio,system-bus,session-bus,ssh-auth,pcsc,cups,gpg-agent,inherit-wayland-socket. this option can be used multiple times.--nosocket=SOCKETβ don't expose a well-known socket to the application. this overrides to the Context section from the application metadata.SOCKETmust be one of:x11,wayland,fallback-x11,pulseaudio,system-bus,session-bus,ssh-auth,pcsc,cups,gpg-agent,inherit-wayland-socket. this option can be used multiple times.--device=DEVICEβ expose a device to the application. this overrides to the Context section from the application metadata.DEVICEmust be one of:dri,input,usb,kvm,shm,all. this option can be used multiple times.--nodevice=DEVICEβ don't expose a device to the application. this overrides to the Context section from the application metadata.DEVICEmust be one of:dri,input,usb,kvm,shm,all. this option can be used multiple times.--allow=FEATUREβ allow access to a specific feature. this updates the[Context]group in the metadata.FEATUREmust be one of:devel,multiarch,bluetooth,canbus,per-app-dev-shm. this option can be used multiple times.
see flatpak-build-finish(1) for the meaning of the various features. π
--disallow=FEATUREβ disallow access to a specific feature. this updates the[Context]group in the metadata.FEATUREmust be one of:devel,multiarch,bluetooth,canbus,per-app-dev-shm. this option can be used multiple times.--filesystem=FILESYSTEM[:ro|:create]β allow the application access to a subset of the filesystem. this overrides to the Context section from the application metadata.FILESYSTEMcan be one of:home,host,host-os,host-etc,host-root,xdg-desktop,xdg-documents,xdg-download,xdg-music,xdg-pictures,xdg-public-share,xdg-templates,xdg-videos,xdg-run,xdg-config,xdg-cache,xdg-data, an absolute path, or a homedir-relative path like~/diror paths relative to the xdg dirs, likexdg-download/subdir. the optional:rosuffix indicates that the location will be read-only. the optional:createsuffix indicates that the location will be read-write and created if it doesn't exist. this option can be used multiple times. see the"[Context] filesystems"list inflatpak-metadata(5)for details of the meanings of these filesystems.
ok important lore: before flatpak1.17.0, access tohostwas granted by default. she used to be that generous. π
--nofilesystem=FILESYSTEMβ remove access to the specified subset of the filesystem from the application. this overrides to the Context section from the application metadata.FILESYSTEMcan be one of:home,host,host-os,host-etc,host-rootxdg-desktop,xdg-documents,xdg-download,xdg-music,xdg-pictures,xdg-public-share,xdg-templates,xdg-videos, an absolute path, or a homedir-relative path like~/dir. this option can be used multiple times.--with-appdirβ expose and configure access to the per-app storage directory in$HOME/.var/app. this is not normally useful when building, but it helps when testing built apps. so like, not for the build build, but for the after. π§ͺ--add-policy=SUBSYSTEM.KEY=VALUEβ add generic policy option. for example,"--add-policy=subsystem.key=v1 --add-policy=subsystem.key=v2"would map to this metadata:
[Policy subsystem]
key=v1;v2;
this option can be used multiple times.
--remove-policy=SUBSYSTEM.KEY=VALUEβ remove generic policy option. this option can be used multiple times. bye bye policy. π--env=VAR=VALUEβ set an environment variable in the application. this overrides to the Context section from the application metadata. this option can be used multiple times.--unset-env=VARβ unset an environment variable in the application. this overrides theunset-environmententry in the[Context]group of the metadata, and the[Environment]group. this option can be used multiple times.--env-fd=FDβ read environment variables from the file descriptorFD, and set them as if via--env. this can be used to avoid environment variables and their values becoming visible to other users. π
each environment variable is in the form VAR=VALUE followed by a zero byte. this is the same format used by env -0 and /proc/*/environ.
--own-name=NAMEβ allow the application to own the well-known nameNAMEon the session bus. this overrides to the Context section from the application metadata. this option can be used multiple times. main character energy, she owns the name literally. π--talk-name=NAMEβ allow the application to talk to the well-known nameNAMEon the session bus. this overrides to the Context section from the application metadata. this option can be used multiple times.--system-own-name=NAMEβ allow the application to own the well-known nameNAMEon the system bus. this overrides to the Context section from the application metadata. this option can be used multiple times.--system-talk-name=NAMEβ allow the application to talk to the well-known nameNAMEon the system bus. this overrides to the Context section from the application metadata. this option can be used multiple times.--persist=FILENAMEβ if the application doesn't have access to the real homedir, make the (homedir-relative) pathFILENAMEa bind mount to the corresponding path in the per-application directory, allowing that location to be used for persistent data. this overrides to the Context section from the application metadata. this option can be used multiple times. it persists. like the group chat. π--sdk-dir=DIRβ normally, if there's ausrdirectory in the build dir, this is used for the runtime files (this can be created by--writable-sdkor--type=runtimearguments tobuild-init). if you specify--sdk-dir, this directory will be used instead. use this if you passed--sdk-dirtobuild-init. matching sets, bestie. π--readonlyβ mount the normally writable destination directories read-only. this can be useful if you want to run something in the sandbox but guarantee that it doesn't affect the build results. for example tests. π§ͺβ¨--metadata=FILEβ use the specified filename as metadata in the exported app instead of the default file (calledmetadata). this is useful if you build multiple things from a single build tree (such as both a platform and a sdk). multi-tasking queen. π--log-session-busβ log session bus traffic. this can be useful to see what access you need to allow in your D-Bus policy.--log-system-busβ log system bus traffic. this can be useful to see what access you need to allow in your D-Bus policy.
π₯ EXAMPLES π₯
$ flatpak build /build/my-app rpmbuild my-app.src.rpm
that's the whole example and honestly? it ate. π
π¦ SEE ALSO π¦
flatpak(1), flatpak-build-init(1), flatpak-build-finish(1), flatpak-build-export(1)
okay that's the page!! this came from the flatpak manual, page FLATPAK BUILD(1), and that footer energy is all hers π go build something gorgeous bestie, ily, no cap β¨π«Ά
π¦ where this page comes from
- fedora 44: flatpak 1.18.4-1.fc44 Β· LGPL-2.1-or-later
- fedora 44: flatpak 1.18.4-1.fc44 Β· LGPL-2.1-or-later
- nixpkgs unstable: flatpak 1.18.4
- ubuntu stonking: flatpak 1.18.4-1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms