Add README
This commit is contained in:
parent
34bad86b5d
commit
7653e724f3
74
README.md
Normal file
74
README.md
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
# arduino-nix
|
||||||
|
|
||||||
|
A flake that allows building an `arduino-cli` environment with certain packages and libraries pre-installed.
|
||||||
|
|
||||||
|
## 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
|
||||||
|
{
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||||
|
flake-utils.url = "github:numtide/flake-utils";
|
||||||
|
arduino-nix.url = "github:bouk/arduino-nix";
|
||||||
|
arduino-library-index = {
|
||||||
|
url = "github:bouk/arduino-indexes/library_index";
|
||||||
|
flake = false;
|
||||||
|
};
|
||||||
|
arduino-package-index = {
|
||||||
|
url = "github:bouk/arduino-indexes/package_index";
|
||||||
|
flake = false;
|
||||||
|
};
|
||||||
|
arduino-package-rp2040-index = {
|
||||||
|
url = "github:bouk/arduino-indexes/package_rp2040_index";
|
||||||
|
flake = false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs = {
|
||||||
|
self,
|
||||||
|
nixpkgs,
|
||||||
|
flake-utils,
|
||||||
|
arduino-nix,
|
||||||
|
arduino-package-index,
|
||||||
|
arduino-package-rp2040-index,
|
||||||
|
arduino-library-index,
|
||||||
|
...
|
||||||
|
}@attrs:
|
||||||
|
let
|
||||||
|
overlays = [
|
||||||
|
(arduino-nix.overlay)
|
||||||
|
(arduino-nix.mkArduinoPackageOverlay (arduino-package-index + "/package_index.json"))
|
||||||
|
(arduino-nix.mkArduinoPackageOverlay (arduino-package-rp2040-index + "/package_rp2040_index.json"))
|
||||||
|
(arduino-nix.mkArduinoLibraryOverlay (arduino-library-index + "/library_index.json"))
|
||||||
|
];
|
||||||
|
in
|
||||||
|
(flake-utils.lib.eachDefaultSystem (system:
|
||||||
|
let
|
||||||
|
pkgs = (import nixpkgs) {
|
||||||
|
inherit system overlays;
|
||||||
|
};
|
||||||
|
in rec {
|
||||||
|
packages.arduino-cli = pkgs.wrapArduinoCLI {
|
||||||
|
libraries = with pkgs.arduinoLibraries; [
|
||||||
|
(arduino-nix.latestVersion ADS1X15)
|
||||||
|
(arduino-nix.latestVersion Ethernet_Generic)
|
||||||
|
(arduino-nix.latestVersion SCL3300)
|
||||||
|
(arduino-nix.latestVersion TMCStepper)
|
||||||
|
(arduino-nix.latestVersion pkgs.arduinoLibraries."Adafruit PWM Servo Driver Library")
|
||||||
|
];
|
||||||
|
|
||||||
|
packages = with pkgs.arduinoPackages; [
|
||||||
|
platforms.arduino.avr."1.6.23"
|
||||||
|
platforms.rp2040.rp2040."2.3.3"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
));
|
||||||
|
}
|
||||||
|
```
|
15
lib.nix
15
lib.nix
@ -4,6 +4,21 @@ let
|
|||||||
in
|
in
|
||||||
with builtins; rec {
|
with builtins; rec {
|
||||||
latestVersion = attrs: (builtins.head (builtins.sort (a: b: (builtins.compareVersions a.version b.version) == 1) (builtins.attrValues (builtins.mapAttrs (version: value: { inherit version value; }) attrs)))).value;
|
latestVersion = attrs: (builtins.head (builtins.sort (a: b: (builtins.compareVersions a.version b.version) == 1) (builtins.attrValues (builtins.mapAttrs (version: value: { inherit version value; }) attrs)))).value;
|
||||||
|
|
||||||
|
# From tools.go in arduino-cli
|
||||||
|
# regexpLinuxArm = regexp.MustCompile("arm.*-linux-gnueabihf")
|
||||||
|
# regexpLinuxArm64 = regexp.MustCompile("(aarch64|arm64)-linux-gnu")
|
||||||
|
# regexpLinux64 = regexp.MustCompile("x86_64-.*linux-gnu")
|
||||||
|
# regexpLinux32 = regexp.MustCompile("i[3456]86-.*linux-gnu")
|
||||||
|
# regexpWindows32 = regexp.MustCompile("i[3456]86-.*(mingw32|cygwin)")
|
||||||
|
# regexpWindows64 = regexp.MustCompile("(amd64|x86_64)-.*(mingw32|cygwin)")
|
||||||
|
# regexpMac64 = regexp.MustCompile("x86_64-apple-darwin.*")
|
||||||
|
# regexpMac32 = regexp.MustCompile("i[3456]86-apple-darwin.*")
|
||||||
|
# regexpMacArm64 = regexp.MustCompile("arm64-apple-darwin.*")
|
||||||
|
# regexpFreeBSDArm = regexp.MustCompile("arm.*-freebsd[0-9]*")
|
||||||
|
# regexpFreeBSD32 = regexp.MustCompile("i?[3456]86-freebsd[0-9]*")
|
||||||
|
# regexpFreeBSD64 = regexp.MustCompile("amd64-freebsd[0-9]*")
|
||||||
|
|
||||||
selectSystem = system: systems:
|
selectSystem = system: systems:
|
||||||
if system == "aarch64-darwin" then
|
if system == "aarch64-darwin" then
|
||||||
alt (lib.findFirst ({host, ...}: (match "arm64-apple-darwin.*" host) != null) null systems) (selectSystem "x86_64-darwin" systems)
|
alt (lib.findFirst ({host, ...}: (match "arm64-apple-darwin.*" host) != null) null systems) (selectSystem "x86_64-darwin" systems)
|
||||||
|
14
packages.nix
14
packages.nix
@ -1,17 +1,3 @@
|
|||||||
# From tools.go in arduino-cli
|
|
||||||
# regexpLinuxArm = regexp.MustCompile("arm.*-linux-gnueabihf")
|
|
||||||
# regexpLinuxArm64 = regexp.MustCompile("(aarch64|arm64)-linux-gnu")
|
|
||||||
# regexpLinux64 = regexp.MustCompile("x86_64-.*linux-gnu")
|
|
||||||
# regexpLinux32 = regexp.MustCompile("i[3456]86-.*linux-gnu")
|
|
||||||
# regexpWindows32 = regexp.MustCompile("i[3456]86-.*(mingw32|cygwin)")
|
|
||||||
# regexpWindows64 = regexp.MustCompile("(amd64|x86_64)-.*(mingw32|cygwin)")
|
|
||||||
# regexpMac64 = regexp.MustCompile("x86_64-apple-darwin.*")
|
|
||||||
# regexpMac32 = regexp.MustCompile("i[3456]86-apple-darwin.*")
|
|
||||||
# regexpMacArm64 = regexp.MustCompile("arm64-apple-darwin.*")
|
|
||||||
# regexpFreeBSDArm = regexp.MustCompile("arm.*-freebsd[0-9]*")
|
|
||||||
# regexpFreeBSD32 = regexp.MustCompile("i?[3456]86-freebsd[0-9]*")
|
|
||||||
# regexpFreeBSD64 = regexp.MustCompile("amd64-freebsd[0-9]*")
|
|
||||||
|
|
||||||
{ fetchzip, stdenv, lib, packageIndex, pkgsBuildHost, pkgs, arduinoPackages }:
|
{ fetchzip, stdenv, lib, packageIndex, pkgsBuildHost, pkgs, arduinoPackages }:
|
||||||
|
|
||||||
with builtins;
|
with builtins;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user