Rename to arduino-sketch-builder-nix
This commit is contained in:
60
README.md
60
README.md
@@ -1,45 +1,41 @@
|
|||||||
# arduino-nix
|
# arduino-sketch-builder-nix
|
||||||
|
|
||||||
A flake that allows building an `arduino-cli` environment with certain packages and libraries pre-installed.
|
A flake that allows building Arduino sketches with nix.
|
||||||
|
|
||||||
|
This project is based on [arduino-nix](https://github.com/bouk/arduino-nix).
|
||||||
|
|
||||||
## Example
|
## Example
|
||||||
|
|
||||||
You need to provide a package index and library index to use `arduino-nix`. You can find some at [arduino-indexes](https://github.com/bouk/arduino-indexes).
|
|
||||||
|
|
||||||
Alternatively, you can download them at https://downloads.arduino.cc/packages/package_index.json and https://downloads.arduino.cc/libraries/library_index.json
|
|
||||||
|
|
||||||
From the indexes you create overlays which then make the Arduino packages and libraries available for the wrapArduinoCLI function provided by this flake.
|
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||||
flake-utils.url = "github:numtide/flake-utils";
|
arduino-sketch-builder-nix.url = "git+https://git.clerie.de/clerie/arduino-sketch-builder-nix";
|
||||||
arduino-nix.url = "github:bouk/arduino-nix";
|
|
||||||
arduino-index = {
|
arduino-index = {
|
||||||
url = "github:bouk/arduino-indexes";
|
url = "github:bouk/arduino-indexes";
|
||||||
flake = false;
|
flake = false;
|
||||||
};
|
};
|
||||||
|
arduino-esp32 = {
|
||||||
|
url = "github:espressif/arduino-esp32/gh-pages";
|
||||||
|
flake = false;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = {
|
outputs = {
|
||||||
self,
|
self,
|
||||||
nixpkgs,
|
nixpkgs,
|
||||||
flake-utils,
|
arduino-sketch-builder-nix,
|
||||||
arduino-nix,
|
|
||||||
arduino-index,
|
arduino-index,
|
||||||
|
arduino-esp32,
|
||||||
...
|
...
|
||||||
}@attrs:
|
}@attrs:
|
||||||
let
|
let
|
||||||
overlays = [
|
overlays = [
|
||||||
(arduino-nix.overlay)
|
(arduino-sketch-builder-nix.overlay)
|
||||||
(arduino-nix.mkArduinoPackageOverlay (arduino-index + "/index/package_index.json"))
|
(arduino-sketch-builder-nix.mkArduinoPackageOverlay (arduino-index + "/index/package_index.json"))
|
||||||
(arduino-nix.mkArduinoPackageOverlay (arduino-index + "/index/package_rp2040_index.json"))
|
(arduino-sketch-builder-nix.mkArduinoPackageOverlay (arduino-index + "/index/package_rp2040_index.json"))
|
||||||
(arduino-nix.mkArduinoLibraryOverlay (arduino-index + "/index/library_index.json"))
|
(arduino-sketch-builder-nix.mkArduinoLibraryOverlay (arduino-index + "/index/library_index.json"))
|
||||||
(arduino-nix.mkArduinoPackageOverlay (pkgs.fetchurl {
|
(arduino-sketch-builder-nix.mkArduinoPackageOverlay (arduino-esp32 + "/package_esp32_index.json"))
|
||||||
url = "https://raw.githubusercontent.com/espressif/arduino-esp32/8bae7e23376c6087a55e46456049ae6d73b72e16/package_esp32_index.json";
|
|
||||||
hash = "sha256-0kvZeRDtE/JKJes86omyN4cf4HWfX68P7xPfE+BvTC8=";
|
|
||||||
}))
|
|
||||||
];
|
];
|
||||||
in
|
in
|
||||||
(flake-utils.lib.eachDefaultSystem (system:
|
(flake-utils.lib.eachDefaultSystem (system:
|
||||||
@@ -51,11 +47,11 @@ From the indexes you create overlays which then make the Arduino packages and li
|
|||||||
# arduinoEnv provides bin/arduino-cli and some useful helpers functions
|
# arduinoEnv provides bin/arduino-cli and some useful helpers functions
|
||||||
arduinoEnv = pkgs.makeArduinoEnv {
|
arduinoEnv = pkgs.makeArduinoEnv {
|
||||||
libraries = with pkgs.arduinoLibraries; [
|
libraries = with pkgs.arduinoLibraries; [
|
||||||
(arduino-nix.latestVersion ADS1X15)
|
(arduino-sketch-builder-nix.latestVersion ADS1X15)
|
||||||
(arduino-nix.latestVersion Ethernet_Generic)
|
(arduino-sketch-builder-nix.latestVersion Ethernet_Generic)
|
||||||
(arduino-nix.latestVersion SCL3300)
|
(arduino-sketch-builder-nix.latestVersion SCL3300)
|
||||||
(arduino-nix.latestVersion TMCStepper)
|
(arduino-sketch-builder-nix.latestVersion TMCStepper)
|
||||||
(arduino-nix.latestVersion pkgs.arduinoLibraries."Adafruit PWM Servo Driver Library")
|
(arduino-sketch-builder-nix.latestVersion pkgs.arduinoLibraries."Adafruit PWM Servo Driver Library")
|
||||||
];
|
];
|
||||||
|
|
||||||
packages = with pkgs.arduinoPackages; [
|
packages = with pkgs.arduinoPackages; [
|
||||||
@@ -101,7 +97,15 @@ From the indexes you create overlays which then make the Arduino packages and li
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## Interactive arduino-cli usage:
|
### Package and library index
|
||||||
|
|
||||||
|
You need to provide a package index and library index. You can use [arduino-indexes](https://github.com/bouk/arduino-indexes) as a collection of common indexes. Accessing them via this git repo allows Nix Flakes to pin them as an input.
|
||||||
|
|
||||||
|
Alternatively, you can just download and check in the official Arduino indexes:
|
||||||
|
- <https://downloads.arduino.cc/packages/package_index.json>
|
||||||
|
- <https://downloads.arduino.cc/libraries/library_index.json>
|
||||||
|
|
||||||
|
### Interactive arduino-cli usage:
|
||||||
|
|
||||||
```
|
```
|
||||||
nix shell .#arduinoEnv
|
nix shell .#arduinoEnv
|
||||||
@@ -109,7 +113,7 @@ nix shell .#arduinoEnv
|
|||||||
|
|
||||||
This adds a wrapped version of `arduino-cli` to your path that reflects you Arduino environment.
|
This adds a wrapped version of `arduino-cli` to your path that reflects you Arduino environment.
|
||||||
|
|
||||||
## Build Arduino Sketch
|
### Build Arduino Sketch
|
||||||
|
|
||||||
```
|
```
|
||||||
nix build .#my-rp2040-project
|
nix build .#my-rp2040-project
|
||||||
@@ -117,7 +121,7 @@ nix build .#my-rp2040-project
|
|||||||
|
|
||||||
Now you have `result` in your current working directory containing the compile outputs.
|
Now you have `result` in your current working directory containing the compile outputs.
|
||||||
|
|
||||||
## Upload to board
|
### Upload to board
|
||||||
|
|
||||||
```
|
```
|
||||||
nix run .#my-rp2040-project.uploadArduinoSketch -- -p /dev/ttyUSB0
|
nix run .#my-rp2040-project.uploadArduinoSketch -- -p /dev/ttyUSB0
|
||||||
|
|||||||
Reference in New Issue
Block a user