Providing environment for The Embedded Rust Book

I’m trying to set up the environment required by The Embedded Rust Book. Ideally I’d like to be able to package it all up in a single shell.nix (preferably portable across NixOS and non-NixOS) but I suspect that the udev rules can’t be set there.

Has anyone tried defining this environment in Nix?

Specifically I’m a bit lost on

  • how to get multiarch support in gdb

  • the Nix equivalent of qemu-system-arm

  • how to add the required udev rules under NixOS (solved here)

  • I’m using the Oxalica Rust Overlay. I know how to express

    • rustup target add thumbv7em-none-eabihf
    • cargo component add llvm-tools-preview

    in terms of targets and extensions in an override, but I don’t know what would be the declarative equivalent of

    • cargo install cargo-binutils
    • cargo install cargo-generate

Do you have any hints?


AFAICT, adding the following to /etc/nixos/configuration.nix

  users.extraGroups.plugdev = { };
  users.extraUsers.<username>.extraGroups = [ "plugdev" "dialout" ];

  services.udev.packages = [ pkgs.openocd ];

seems to do the trick.

Credit: Running OpenOCD without root privileges — theCore documentation

1 Like
  • Add gdb-multitarget to your shell
  • Add qemu to your shell
  • You can probably just add cargo-binutils and cargo-generate from nixpkgs to your shell. Without some overlay trickery they won’t be built against the same cargo version as your overlay, but should still work as long as the versions don’t diverge too much.

Also, you should use niv to lock your dependency versions to ensure reproducibility.

1 Like