Snapcraft app and service metadata


#1

The app keys and values in snapcraft.yaml detail the applications and services that a snap wants to expose, including how they’re executed and which resources they can access.

See Snapcraft top-level metadata and Snapcraft parts metadata for details on how apps and parts are configured within snapcraft.yaml.

Name Description
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>.

The following are keys that can be within apps.<app-name> (for example, apps.<app-name>.daemon):

Name Description
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 excecutable placed under $SNAP/bin. With classic confinement, bin/app-launch for an executable placed under $SNAP/bin.
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.
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
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.
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
plugs
 
Plugs for interfaces to connect to.
Type: list[string]
<app-name> will make these plug connections when running in strict confinement For interfaces that need attributes, see top-level plugs.
Example: [home, removable-media, raw-usb]
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]
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.
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.
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.
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.
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.
socket-mode
 
The mode of a socket in octal.
Type: integer
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/and@snap.<snap 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.

Snapcraft parts metadata
Snapcraft overview
The snapcraft format