Skip to content

Conversation

@simojo
Copy link

@simojo simojo commented Nov 14, 2024

This PR adds a way to include an attribute set that modifies platform.txt located at packages/${name}/hardware/${architecture}/${version}/platform.txt. I created this feature as a way to sidestep some issues I encountered when compiling for the Digispark.

Overview

The functionality allows you to provide the attrset argument called buildProperties to mkArduinoPackageOverlay in the same manner you would call:

arduino-cli --build-property KEY=VALUE

Example

Calling mkArduinoPackageOverlay while specifying custom buildProperties looks like the following:

      (arduino-nix.mkArduinoPackageOverlay {
        packageIndexFile = (arduino-index + "/index/package_digistump_index.json");
        buildProperties = {
          "KEY1" = "VALUE1";
          "KEY2" = "VALUE2";
        };
      })

which corresponds to platform.txt looking like the following:

...
KEY1=VALUE1
KEY2=VALUE2
...

Note that, if the key did not already exist in platform.txt, it would be appended on a new line. Otherwise, it is appended to the same line with a space.

The caveat (suggestions, anyone?)

Calling mkArduinoPackageOverlay without specifying any extra buildProperties would need to look like this now:

-(arduino-nix.mkArduinoPackageOverlay (arduino-index + "/index/package_index.json"))
+(arduino-nix.mkArduinoPackageOverlay { packageIndexFile = (arduino-index + "/index/package_index.json"); })

which is obviously non-optimal. I'm open to suggestions for how to make this better, as I'm still learning the nix lang.

@simojo
Copy link
Author

simojo commented Dec 2, 2024

@bouk would you mind weighing in on this feature?

@bouk
Copy link
Owner

bouk commented Dec 2, 2024

Hi @simojo, thanks for taking the time to create this PR.

I don't think this is needed however, if you want to modify a platform you can do something like:

`platforms.rp2040.rp2040."version".overrideAttrs (self: super: {
  fixupPhase = "...";
})

Which is what we do for something similar. I would accept a PR that updates the README to include this information 😄

@simojo
Copy link
Author

simojo commented Dec 2, 2024

Sounds good, I'll make a mental note to update the docs README so others who need something similar can see it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants