The Wayback Machine - https://web.archive.org/web/20201025165631/https://snapcraft.io/docs/snapcraft-yaml-reference

Snapcraft.yaml reference

This page arranges the same material found in The snapcraft format as a single page.

Name Description
name
mandatory
The identifying name of the snap.
Type: string
It must start with an ASCII character and can only contain letters in lower case, numbers, and hyphens, and it can’t start or end with a hyphen. The name must be unique if you want to publish to the Snap Store.
For help on choosing a name and registering it on the Snap Store, see Registering your app name.
Example: my-awesome-app
title
optional
The canonical title of the application, displayed in the software centre graphical frontends.
Type: string
Max length 40 characters.
In the legacy Snapcraft syntax (prior to the base key), this key is only available through the passthrough key.
Example: My Awesome Application
base
optional
A snap of type base to be used as the execution environment for this snap.
Example: core18
version
mandatory
A user facing version to display.
Type: string
Max len. 32 chars. Needs to be wrapped with single-quotes when the value will be interpreted by the YAML parser as non-string
Examples: '1', '1.2', '1.2.3', git (will be replaced by a git describe based version string)
version-script
deprecated
Deprecated Use snapcraftctl set-version part scriptlet instead.
A command to determine the snap’s version string
Type: string
Runs from the working directory of the source tree root, and prints a version string to the standard output. Replaces the value of the version keyword. The version keyword is still mandatory (but ignored).
summary
mandatory
Sentence summarising the snap.
Type: string
Max len. 78 characters, describing the snap in short and simple terms.
Example: The super cat generator
description
mandatory
Multi-line description of the snap.
Type: string
A more in-depth look at what your snap does and who may find it most useful.
type
optional
The type of snap, implicitly set to app if not set.
Type: enum
For more details, see: gadget, kernel and base
confinement
optional
Determines if the snap should be restricted in access or not.
Type: enum
Possible values are strict (for no access outside of declared interfaces through plugs), devmode (for unrestricted access) or classic. For more information, refer to Confinement
Examples: strict, or devmode
icon
optional
Path to icon image that represents the snap in the snapcraft.io store pages and other graphical store fronts.
Note that the desktop menu does not use this icon. It uses the icon in the .desktop file of the application.
Type: string
It is a relative path to a .png or .svg file from the source tree root. The recommended size is 256x256 pixels. Aspect ratio needs to be 1:1. Image size can vary from 40x40 to 512x512 px and the file size should not be larger than 256 KB.
Examples: _package_name_.svg, or snap/gui/logo.png
license
optional
A license for the snap in the form of an SPDX expression for the license. In the legacy Snapcraft syntax (not using the base key), this key is only available through the passthrough key. Currently, only SPDX 2.1 expressions are supported, refer snapd/licenses.go at master · snapcore/snapd for accepted expressions.
Type: string
Examples: GPL-3.0, MIT, Proprietary
grade
optional
Defines the quality grade of the snap.
Type: enum
Can be either devel (i.e. a development version of the snap, so not to be published to the stable or candidate channels) or stable (i.e. a stable release or release candidate, which can be released to all channels)
Example: [stable or devel]
adopt-info
optional
Incorporate external metadata via the referenced part.
Type: string
See Using external metadata for more details.
architectures
optional
List of build and run architectures.
Type: list[object]
For more details, see Architectures.
assumes
optional
A list of features that must be supported by the core in order for this snap to install. For example, to make the snap only installable on certain recent version of snapd (like 2.38) you can specify: - snapd2.38. See Snapcraft top-level metadata for other potential values.
Type: list[string]
passthrough
optional
Attributes to passthrough to snap.yaml without validation from snapcraft.
Type: type[object]
See Using development features in snapcraft for more details.
apps A map of app-names representing entry points to run for the snap.
Type: dict
apps.
<app-name>
The name exposed to run a program inside the snap.
Type: dict
If <app-name> is the same as name, the program will be invoked as app-name. However, if they differ, the program will be exposed as <snap-name>.<app-name>.
apps.
<app-name>.
adapter
Controls the creation of an env variable wrapper.
Type enum
Can be one of the following:
- none
- full (default)
Snapcraft normally creates a wrapper holding common environment variables. Disabling this could be useful for minimal base snaps without a shell, and for statically linked binaries with no use for an environment.
apps.
<app-name>.
autostart
The name of the autostart .desktop file.
Type: string
The desktop file is placed in $SNAP_USER_DATA/.config/autostart, and the application is started using the app’s command wrapper. See Snapcraft parts metadata for further details.
apps.
<app-name>.
command
The command to run inside the snap when <app-name> is invoked.
Type: string
The command can be in either a snap runtime’s command path, $SNAP/usr/sbin:$SNAP/usr/bin:$SNAP/sbin:$SNAP/bin, or an executable path relative to $SNAP.
If daemon is set, this will be the command to run the service.
Only a snap with classic confinement can use a relative path because PATH isn’t modified by a wrapper in classic confinement. See Classic confinement for more details.
Examples: app-launch for an executable placed under $SNAP/bin. With classic confinement, bin/app-launch for an executable placed under $SNAP/bin.
apps.
<app-name>.
command-chain
A list of commands to be executed prior to apps.<app-name>.command.
Type: string
The list is executed, in order, before running the apps.<app-name>.command.
See Proposal: support command-chain in apps and hooks for more details.
To ensure that the Snapd distribution user running supports this feature, insert the command-chain value to the assumes property.
apps.
<app-name>.
common-id
An identifier to a desktop-id within an external appstream file.
Type: string
See Using external metadata for more details.
apps.
<app-name>.
daemon
Declares that <app-name> is a system daemon.
Type: enum
Can be one of the following:
- simple: the command is the main process.
- oneshot: the configured command will exit after completion
- forking: the configured command calls fork() as part of its start-up. The parent process is then expected to exit when start-up is complete
- notify: the command configured will send a signal to systemd to indicate that it’s running.
apps.
<app-name>.
desktop
Location of the .desktop file.
Type: string
A path relative to the prime directory pointing to a desktop file, commonly used to add an application to the launch menu. Snapcraft will take care of the rest.
Examples: usr/share/applications/my-app.desktop and share/applications/my-app.desktop
apps.
<app-name>.
environment
A set of key-value pairs specifying the contents of environment variables.
Type: dict
Key is the environment variable name; Value is the contents of the environment variable.
Example: LANG: C.UTF-8
apps.
<app-name>.
extensions
Extensions to apply to this application.
Type: list[string]
Example: [gnome-3-28]
apps.
<app-name>.
plugs
Plugs for interfaces to connect to.
Type: list[string]
apps.
<app-name>.
slots
Slots for interfaces to connect to.
Type: list[string]
<app-name> will make these slot connections when running in strict confinement only. For interfaces that need attributes, see top-level slots.
Example: [home, removable-media, raw-usb]
apps.
<app-name>.
stop-command
The path to a command inside the snap to run to stop the service.
Type: string
Requires daemon to be set as the snap type.
apps.
<app-name>.
post-stop-command
Runs a command from inside the snap after a service stops
Type: string
Requires daemon to be set as the snap type.
apps.
<app-name>.
stop-timeout
The length of time to wait before terminating a service.
Type: string
Time duration units can be 10ns, 10us, 10ms, 10s, 10m. Termination is via SIGTERM (and SIGKILL if that doesn’t work).
Requires daemon to be set as the snap type.
apps.
<app-name>.
timer
Schedules when, or how often, to run a service or command.
Type: timer string
See Timer string format for further details on the required syntax.
Requires daemon to be set as the snap type.
apps.
<app-name>.
restart-condition
Condition to restart the daemon under.
Type: enum
Defaults to on-failure. Other values are [on-failure|on-success|on-abnormal|on-abort|always|never]. Refer to systemd.service manual for details.
Requires daemon to be set as the snap type.
apps.
<app-name>.
socket
Maps a daemon’s sockets to services and activates them.
Type: dict
Requires an activated daemon socket.
Requires apps.<app-name>.plugs to declare the network-bind plug.
apps.
<app-name>.
socket-mode
The mode of a socket in octal.
Type: integer
apps.
<app-name>.
listen-stream
The socket abstract name or socket path.
Type: string
Sockets should go to a map of <socket-name> to objects which specify the listen-stream and (optionally) the socket-mode.
TCP socket syntax: \<port\>, [::]:\<port\>, [::1]:\<port\> and 127.0.0.1:\<port\>
UNIX socket syntax: $SNAP_DATA/\<path\>, $SNAP_COMMON/<path> and @snap.\<snap name\>.<suffix>
apps.
<app-name>.
passthrough
<app-name> attributes to pass through to snap.yaml without snapcraft validation.
Type: type[object]
See Using in-development features for further details.
plugs
optional
A set of plugs that the snap asserts.
Type: dict
These plugs apply to all apps and differs from apps.<app-name>.plugs in that the type is in a dict rather than a list format, :(colon) must be postfixed to the interface name and shouldn’t start with -(dash-space)
plugs.
<plug-name>
optional
A set of attributes for a plug
Type: dict
Example: read attribute for the home interface
plugs.
<plug-name>.
<attribute-name>
optional
Value of the attribute
Type: string
Example: all for read attribute of the home interface
slots
optional
A set of slots that the snap provides.
Type: dict
These slots apply to all the apps
slots.
<slot-name>
optional
A set of attributes of the slot
Type: dict
slots.
<slot-name>.
<attribute-name>
optional
Value of the attribute
Type: dict
parts
A set of independent building blocks.
Type: dict
These independent building blocks are known as parts, and consist of either code or pre-built packages.
parts.
<part-name>
The name of the part building block.
Type: dict
<part-name> represents the specific name of a building block which can be then referenced by the command line tool (i.e. snapcraft).
parts.
<part-name>.
plugin
The plugin to drive the build process.
Type: string
Every part drives its build through a plugin, this entry declares the plugin that will drive the build process for <part-name>. Refer to snapcraft plugins for more information on the available plugins and the specific attributes they add to the parts.<part-name>. namespace.
parts.
<part-name>.
source
A URL or path to a source tree to build.
Type: string
This can be a local path or remote, and can refer to a directory tree, a compressed archive or a revision control repository. This entry supports additional syntax, for more information refer to Advanced grammar.
parts.
<part-name>.
source-type
Used when the type-of source entry cannot be detected.
Type: enum
Can be one of the following: [bzr|deb|git|hg|local|mercurial|rpm|subversion|svn|tar|zip|7z]
parts.
<part-name>.
source-checksum
Used when source represents a file.
Type: string
Takes the syntax <algorithm>/<digest>, where <algorithm> can be any of: md5, sha1, sha224, sha256, sha384, sha512, sha3_256, sha3_384 or sha3_512. When set, the source is cached for multiple uses in different snapcraft projects.
parts.
<part-name>.
source-depth
Depth of history for sources using version control.
Type: integer
Source repositories under version control are cloned or checked out with full history. Specifying a depth will truncate the history to the specified number of commits.
parts.
<part-name>.
source-branch
Work on a specific branch for source repositories under version control.
Type: string
parts.
<part-name>.
source-commit
Work on a specific commit for source repositories under version control.
Type: string
parts.
<part-name>.
source-tag
Work on a specific tag for source repositories under version control.
Type: string
parts.
<part-name>.
source-subdir
A path within the source to set as the working directory when building.
Type: string
parts.
<part-name>.
after
Ensures that all the <part-name>s listed in after are staged before this part begins its lifecycle.
Type: list[string]
parts.
<part-name>.
build-environment
Type: list[string]
A list of environment variable assignments that is applied during the build step, it is exported in order which allows for later values to override (or modify) earlier values.
parts.
<part-name>.
build-snaps
A list of snap names to install that are necessary to build <part-name>.
Type: list[string]
If a specific channel is required, the syntax is of the form <snap-name>/<channel>. This entry supports additional syntax, for more information refer to Advanced grammar
parts.
<part-name>.
build-packages
A list of packages required to build a snap.
Type: list[string]
Packages are installed using the host’s package manager, such as apt or dnf, and are required for <part-name> to build correctly. This entry supports additional syntax, for more information refer to Advanced grammar.
Example: [ libssl-dev, libssh-dev, libncursesw5-dev]
parts.
<part-name>.
stage-packages
A list of packages required at runtime by a snap.
Type: list[string]
Packages are installed using the host’s package manager, such as apt or dnf, and are required by <part-name> to run. This entry supports additional syntax, for more information refer to Advanced grammar.
Example: [python-zope.interface, python-bcrypt]
parts.
<part-name>.
stage-snaps
A list of snaps required at runtime by a snap.
Type: list[string]
Snaps are required by <part-name> to run. They are fetched using snap download, and are unpacked into the snap being built. This entry supports additional syntax, for more information refer to Advanced grammar.
Example: [hello, black/latest/edge]
parts.
<part-name>.
organize
A map of files to rename.
Type: dict
In the key/value pair, the key represents the path of a file inside the part and the value represents how the file is going to be staged.
Example: bin/snapcraftctl: bin/scriptlet-bin/snapcraftctl.
parts.
<part-name>.
filesets
A key to represent a group of files, or a single file.
See Snapcraft filesets for further details.
parts.
<part-name>.
stage
A list of files from <part-name> to stage.
Type: list[string]
Rules applying to the list here are the same as those of filesets. Referencing of fileset keys is done with a $ prefixing the fileset key, which will expand with the value of such key.
parts.
<part-name>.
parse-info
Defines the content to adopt when using external metadata.
Type: string
It is a relative path to a supported metadata file from the part source, build or install directory (SNAPCRAFT_PART_SRC, SNAPCRAFT_PART_BUILD, SNAPCRAFT_PART_INSTALL).
See Using external metadata for more details.
parts.
<part-name>.
prime
A list of files from <part-name> to prime.
Type:list[string]
Rules applying to the list here are the same as those of filesets. Referencing of fileset keys is done with a $ prefixing the fileset key, which will expand with the value of such key.
parts.
<part-name>.
prepare
deprecated
The release of Snapcraft 3.0 made this key obsolete.
Use override-build instead.

Runs a script before the plugin’s build step.
Type: multiline string
The script is run before the build step defined for parts.<part-name>.plugin starts. The working directory is the base build directory for the given part. The defined script is run with /bin/sh and set -e.
A set of Environment Variables will be available to the script.
parts.
<part-name>.
override-build
Replaces a plugin’s default build process with a script.
Type: multiline string
The shell script defined here replaces the build step of the plugin, defined in parts.<part-name>.plugin. The working directory is the base build directory for the given part. The defined script is run with /bin/sh and set -e. A set of Environment Variables will be available to the script.
parts.
<part-name>.
override-prime
Replaces a plugin’s default prime process with a script.
Type: multiline string
The shell script defined here replaces the prime step of the plugin, defined in parts.<part-name>.plugin. The working directory is the base prime directory for the given part. The defined script is run with /bin/sh and set -e. A set of Environment Variables will be available to the script.
parts.
<part-name>.
override-pull
Replaces a plugin’s default pull process with a script.
Type: multiline string
The shell script defined here replaces the pull step of the plugin, defined in parts.<part-name>.plugin. The working directory is the base pull directory for the given part. The defined script is run with /bin/sh and set -e. A set of Environment Variables will be available to the script.
parts.
<part-name>.
override-stage
Replaces a plugin’s default stage process with a script.
Type: multiline string
The shell script defined here replaces the stage step of the plugin, defined in parts.<part-name>.plugin. The working directory is the base stage directory for the given part. The defined script is run with /bin/sh and set -e. A set of Environment Variables will be available to the script.
parts.
<part-name>.
install
deprecated
The release of Snapcraft 3.0 made this key obsolete.
Use override-build instead.
Runs a script after the plugin’s build step.
Type: multiline string
The shell script defined here is run after the build step of the plugin defined in parts.<part-name>.plugin starts. The working directory is the base build directory for the given part. The defined script is run with /bin/sh and set -e.
A set of Environment Variables will be available to the script.
parts.
<part-name>.
build-attributes
A list of named attributes to modify the behaviour of plugins.
Type: enum
For more information, refer to Snapcraft parts metadata.

Last updated 4 months ago. Help improve this document in the forum.