Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
description = "Wrapper for arduino-cli";

outputs = { self }: {
mkArduinoPackageOverlay = packageIndexFile: (self: super: {
mkArduinoPackageOverlay = { packageIndexFile, buildProperties ? {} }: (self: super: {
arduinoPackages = self.lib.recursiveUpdate (super.arduinoPackages or {}) (self.callPackage ./packages.nix {
packageIndex = builtins.fromJSON (builtins.readFile packageIndexFile);
buildProperties = buildProperties;
});
});

Expand Down
17 changes: 16 additions & 1 deletion packages.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ fetchzip, stdenv, lib, packageIndex, pkgsBuildHost, pkgs, arduinoPackages }:
{ fetchzip, stdenv, lib, packageIndex, buildProperties, pkgsBuildHost, pkgs, arduinoPackages }:

with builtins;
let
Expand Down Expand Up @@ -57,6 +57,21 @@ let

runHook postInstall
'';
fixupPhase = ''
# Iterate over each key-value pair in buildProperties
# and append/update it accordingly in platform.txt
${
pkgs.lib.concatStringsSep "\n" (pkgs.lib.mapAttrsToList (key: value: ''
if grep -q "^${key}=" "$out/$dirName/platform.txt"; then
# If the line exists, use sed to replace it
sed -i "s|^${key}=.*|& ${value}|" "$out/$dirName/platform.txt"
else
# If the line doesn't exist, add it at the end of the file
echo "${key}=${value}" >> "$out/$dirName/platform.txt"
fi
'') buildProperties)
}
'';
nativeBuildInputs = [ pkgs.unzip ];
src = fetchurl ({
url = url;
Expand Down