This is a template for building reproducible Arduino sketches with the help of Nix, with flakes enabled.
$ nix develop
$ make -C blink compile
$ make -C blink upload
nix develop
provides a reproducible development environment via a Nix flake: arduino-cli
and other system packages are pinned via Nix, but arduino-cli
still downloads its own libraries. These are in turn pinned via the the build profile in the sketch.yaml file.
For NixOS: make sure the user is in the dialout
group to access the serial port.
users.users.<user>.extraGroups = [ "dialout" ];
Current version pinned via nixpkgs
: 0.31.0.
Use make
for some predefined options to compile and upload the sketch.
You may need to modify the options at the top of the Makefile to make the upload work.
You may need to modify the options in sketch.yaml to make it work on a different device (fqbn/platform). In its original state it's set up for the Wemos D1 Mini.
Hints to compile / upload from command line without theMakefile
: https://arduino.github.io/arduino-cli/0.31/getting-started/ .