{ inputs = { rust-overlay.url = "github:oxalica/rust-overlay/stable"; nixpkgs.follows = "rust-overlay/nixpkgs"; }; outputs = { nixpkgs, rust-overlay, ... }: let forAllSystems = f: nixpkgs.lib.genAttrs [ "aarch64-linux" "x86_64-linux" "aarch64-darwin" "x86_64-darwin" ] ( system: f { pkgs = import nixpkgs { inherit system; overlays = [(import rust-overlay)]; }; } ); in { devShells = forAllSystems ({pkgs}: { default = with pkgs; mkShell { packages = [ bashInteractive coreutils diffutils cmake buildPackages.stdenv.cc just openssl pkg-config protobuf cargo-readme # Rust version is pinned to 1.73.0 due to Yocto's meta-rust layer constraints. # Refer to the following URL for the maximum possible version for this pin in # order to package this project as part of Yocto: # # # For a list of the latest stable Rust version releases, visit: # (rust-bin.stable."1.73.0".default.override { extensions = [ "rust-src" "rust-analyzer" ]; }) ]; shellHook = '' # Avoid polluting home dir with local project stuff. if command -v git &> /dev/null; then CARGO_HOME="$(git rev-parse --show-toplevel)/.cargo" export CARGO_HOME export PATH=$PATH:$CARGO_HOME/bin fi ''; # As suggested in the tonic-build documentation: # # On NixOS, it is better to specify the location of `PROTOC` and `PROTOC_INCLUDE` explicitly. # The reason being that if `prost_build::compile_protos` fails to generate the resultant package, # the failure is not obvious until the `include!(concat!(env!("OUT_DIR"), "/resultant.rs"));` # fails with `No such file or directory` error. PROTOC = "${protobuf}/bin/protoc"; PROTOC_INCLUDE = "${protobuf}/include"; }; }); }; }