With a lot of help from Alex Larsson (and everyone in #flatpak) I have created a preliminary extension for the fdo (freedesktop.org) sdk. It is rough around the edges (I would like to see how one uses it streamlined) and it’s only for x86_64 right now but it works and is usable.
I’ve also made a manifest for an existing Rust application as an example of how to use the extension. You can of course build the extension from source but it will take quite some time so I’ve made it available in a repo. The repo is http://repo.sharedpointer.com. You can get its gpg key at http://sharedpointer.com/repo.sharedpointer.com.gpg. The extension is org.freedesktop.Sdk.Extension.rust.
To see the example Rust application manifest look here: https://github.com/futuretim/flatpak-fun/blob/master/com.sharedpointer.mdBook.json.
The main points are that you need to run an install script that is provided with the extension (this makes sure that some libs are in the right place) and then you need to put the binaries in the PATH. The PATH to the extension binaries will follow the pattern /usr/lib/sdk/<extension_name>/bin. In this case the extension name is the last part of the entire extension id. So in this case just “rust”. Once you’ve done that you can invoke rustc and cargo to your hearts’ content.
I hope to have it generalized soon so that we can have it across the platforms that Flatpak supports. Catch up with me as user futuretim on #flatpak on freenode if you have questions or leave them below.