Best practice: Defaults and configurations for snaps customs build


I’m building my own Ubuntu Core builds, which ships with some snaps by default.

These snaps are pulled from the public snap store and aren’t necessarily maintained by me. One example is ufw.

I’m quite new to this, so I’m wondering what are the best practices to ship default configuration files etc for snaps like these.

I have my own custom gadget snap.

Here are some scenarios:

  • I want to set default rules for ufw and enable it by default.
  • Add a custom mosquitto.conf file that is created before (image) build for the mosquiitto snap.
  • Add a settings.json and a user.json to the zwave-js-ui snap and enable it (it’s not enabled as a service by default), including adding a slot/plug connection between the serial-port and pi:bt-serial.

My gadget is a modification of the «pi gadget» with not any vital changes from the official one. There are just some in regards to defaults > system > network in the gadget.yaml and some cmdline.txt and config.txt changes.

I’ve also tried to add connections I’m gadget to solve the serial-port connections, but it doesn’t connect. Not sure if pi:bt-serial is part of «self» (the gadget snap).

Any guidance, tips and recommendations on how these things can be accomplished are welcome :hugs:

Defaults can also go into the gadget as long as they are exposed as snap settings by the respective snaps …

i have some really old appliance images where i did that, here is an example (see the two gadget.yaml files in there) Index of /~ogra/snappy/appliances/fabrica/snaps

for the serial-port connection your gadget needs to have a snap id (which you only get when it is in a (brand) store), then you can do the self-connection in the connections:


Thanks. So it won’t be possible when the the gadget is locally built. I can’t believe I anytime in the future will afford having a brand store.

Is there any way to include physical files, for snaps that doesn’t expose any configuration hooks ? Or will I have to make a new volume in the gadget that includes those files?