Compare commits

...

10 Commits

Author SHA1 Message Date
2fe354b7eb Merge branch 'main' into clerie/arduino-env 2025-10-17 14:05:29 +02:00
Bouke van der Bijl
cfa82ced5b Merge pull request #11 from SFrijters/fetchurl-fix
Use pkgs.fetchurl instead of implicit builtins.fetchurl
2025-09-23 09:42:41 +02:00
Stefan Frijters
d37e988cee Use pkgs.fetchurl instead of implicit builtins.fetchurl
We do not want or need these downloads at eval time,
and it breaks eval/builds in memory-constrained environments.
2025-09-20 14:35:11 +02:00
Bouke van der Bijl
dd6c6f4de7 Merge pull request #8 from srd424/readme-fix
Remove references to different branches from example in README
2024-12-27 21:41:18 +01:00
Steve Dee
6b092895be Remove references to different branches from example in README 2024-12-27 18:20:25 +00:00
Bouke van der Bijl
86e8139e45 Create 'staging' directory
The latest version of the CLI tries to create this dir and errors if it
can't
2024-10-01 16:36:24 +02:00
Bouke van der Bijl
4e0dc359f8 Merge pull request #5 from Schuwi/main
Fix aarch64 architecture recognition
2024-03-11 14:06:07 +01:00
Schuwi
b213bf5bfb Fix aarch64 architecture recognition 2024-03-11 13:44:25 +01:00
fbdd609c0d Correct shell usage example 2023-12-03 18:20:06 +01:00
2263f20c42 Make packages and libraries optional in mkArduinoEnv 2023-12-03 17:13:26 +01:00
6 changed files with 44 additions and 24 deletions

View File

@@ -16,16 +16,8 @@ From the indexes you create overlays which then make the Arduino packages and li
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";
arduino-index = {
url = "github:bouk/arduino-indexes";
flake = false;
};
};
@@ -35,17 +27,15 @@ From the indexes you create overlays which then make the Arduino packages and li
nixpkgs,
flake-utils,
arduino-nix,
arduino-package-index,
arduino-package-rp2040-index,
arduino-library-index,
arduino-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"))
(arduino-nix.mkArduinoPackageOverlay (arduino-index + "/index/package_index.json"))
(arduino-nix.mkArduinoPackageOverlay (arduino-index + "/index/package_rp2040_index.json"))
(arduino-nix.mkArduinoLibraryOverlay (arduino-index + "/index/library_index.json"))
(arduino-nix.mkArduinoPackageOverlay (pkgs.fetchurl {
url = "https://raw.githubusercontent.com/espressif/arduino-esp32/8bae7e23376c6087a55e46456049ae6d73b72e16/package_esp32_index.json";
hash = "sha256-0kvZeRDtE/JKJes86omyN4cf4HWfX68P7xPfE+BvTC8=";
@@ -100,6 +90,12 @@ From the indexes you create overlays which then make the Arduino packages and li
src = ./. + "/my-esp32-poe-iso-project";
fqbn = "esp32:esp32:esp32-poe-iso";
};
};
hydraJobs = {
# Build binary tarball in CI
my-esp32-poe-iso-project = my-esp32-poe-iso-project.binaryTarball;
};
}
));
}
@@ -108,9 +104,11 @@ From the indexes you create overlays which then make the Arduino packages and li
## Interactive arduino-cli usage:
```
nix develop .#arduinoEnv
nix shell .#arduinoEnv
```
This adds a wrapped version of `arduino-cli` to your path that reflects you Arduino environment.
## Build Arduino Sketch
```

View File

@@ -2,8 +2,8 @@
let
mkArduinoEnv = {
packages
, libraries
packages ? []
, libraries ? []
, runtimeInputs ? []
}: let
arduino-cli = pkgs.wrapArduinoCLI {
@@ -49,6 +49,10 @@ let
inherit fqbn;
arduinoSketch = (finalAttrs.finalPackage);
};
binaryTarball = binaryTarball {
inherit name;
arduinoSketch = (finalAttrs.finalPackage);
};
};
});
@@ -58,5 +62,18 @@ let
}: pkgs.writeScriptBin "upload-arduino-sketch" ''
${arduinoEnv}/bin/arduino-cli upload --log --input-dir=${arduinoSketch} --fqbn=${fqbn} "$@"
'';
binaryTarball = {
arduinoSketch
, name
}: pkgs.runCommand "binary-tarball" {} ''
mkdir -p $out
cd ${arduinoSketch}
${pkgs.gnutar}/bin/tar -czf $out/${name}.tar.gz *
mkdir -p $out/nix-support
echo "file binary-dist $out/${name}.tar.gz" > $out/nix-support/hydra-build-products
'';
in
mkArduinoEnv

View File

@@ -27,9 +27,11 @@ with builtins; rec {
else if system == "i686-darwin" then
lib.findFirst ({host, ...}: (match "i[3456]86-apple-darwin.*" host) != null) null systems
else if system == "aarch64-linux" then
lib.findFirst ({host, ...}: (match "(aarch64|arm64)-linux-gnu" host) != null) null systems
# tools.go uses regexp.MatchString which will also return true for substring matches, so we add a .* to the regex
lib.findFirst ({host, ...}: (match "(aarch64|arm64)-linux-gnu.*" host) != null) null systems
else if system == "x86_64-linux" then
lib.findFirst ({host, ...}: (match "x86_64-.*linux-gnu" host) != null) null systems
# also add a .* to the regex here though it is not necessary in the current dataset (March 2024)
lib.findFirst ({host, ...}: (match "x86_64-.*linux-gnu.*" host) != null) null systems
else null;
convertHash = hash: let
m = (match "(SHA-256|SHA-1|MD5):(.*)" hash);

View File

@@ -19,7 +19,7 @@ let
runHook postInstall
'';
nativeBuildInputs = [ pkgs.unzip ];
src = fetchurl ({
src = pkgs.fetchurl ({
url = url;
} // (convertHash checksum));
};

View File

@@ -26,7 +26,7 @@ let
cp -R * "$out/$dirName/"
'';
nativeBuildInputs = [ pkgs.unzip ];
src = fetchurl ({
src = pkgs.fetchurl ({
url = system.url;
} // (convertHash system.checksum));
};
@@ -58,7 +58,7 @@ let
runHook postInstall
'';
nativeBuildInputs = [ pkgs.unzip ];
src = fetchurl ({
src = pkgs.fetchurl ({
url = url;
} // (convertHash checksum));
};

View File

@@ -22,6 +22,9 @@ let
(pkgs.writeTextDir "package_index.json" (builtins.toJSON {packages = [];}))
(pkgs.writeTextDir "library_index.json" (builtins.toJSON {libraries = [];}))
];
postBuild = ''
mkdir -p $out/staging
'';
};
in
pkgs.runCommand "arduino-cli-wrapped" {