Correct snapcraft syntax for Rust-based snap on core22

After some back-and-forth, the following seems to work:

  rust-deps:
    plugin: nil
    build-packages:
      - curl
    override-pull: |
      curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
  xxx:
    plugin: rust
    source: .
    after: [rust-deps]
    build-packages:
      - pkg-config

You may not need pkg-config, but in my case without it the cargo build process wasn’t able to pull in some libraries required by specific crates.

With the above approach anything in rust-toolchain.toml also appears to be respected. An alternative (but I guess less elegant) approach with respect to using a specific toolchain is to install it/set it as default during the override-pull step of rust-deps.

4 Likes