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
Max len. 30 chars, must start with an ASCII character, can only use ASCII lowercase letters, numbers, and hyphens, and must have at least one letter.
Example: my-awesome-app
title
optional
The canonical title of the application, displayed in the software centre graphical frontends.
Type: string
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 A command to determine the snap’s version string
Type: string
Runs from the working directory of the source tree root, and should 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.
Type: string Relative path to a PNG/SVG file from the source tree root.
Example: share/icons/_package_name_.svg
logo.png
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.
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
Disables the creation of an env variable wrapper.
Type enum
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>.
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>.
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>.
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>.
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
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: [git|bzr|hg|svn|tar|deb|rpm|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-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>.
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
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
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>.
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 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>.
install
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 plugins.

Last updated 3 days ago. Help improve this document in the forum.