feat: custom targets #42
No reviewers
Labels
No labels
Compat
Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
4 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: auxolotl/labs#42
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "vlinkz/labs:customtargets"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Allow for passing in custom targets. Along with this feature I added support for cross-compiling to use musl rather than glibc. In order to cross compile something targeting musl, you can run
extraTargetsare essentially anything thatlib.systems.withBuildInfocan consume to turn into a full target system. While support is not implemented yet, you can imagine doing something like:On the package side, we can check these platform options and use the appropriate tool/configuration.
I really don't like the
argpattern. Why would we use this instead of writing a Nix expression (in an file) and building that instead?@jakehamilton wrote in #42 (comment):
That was just to have a quick one-liner example. But I imagine actual consumers of tidepool would define extraTargets in a file when importing (similarly to how nixpkgs import defines overlays, system, etc).
@vlinkz why not use the module system them?
@jakehamilton wrote in #42 (comment):
It does, you can set
config.systems.extraTargets. Setting module option in lib is ok right?systems.extraTargets = (Right, so why is Tidepool now a function that requires taking an argument if we would rather set things on the module? It seems like this makes it less friendly/more complex to import.
Hm good point, in that I was trying to make it easier to test, but we could make a separate file for such use cases and leave default.nix as is. Lemme try that
22da4d7196to0d8ad0c11b@jakehamilton wrote in #42 (comment):
Updated to no longer use arg. Added updated examples for building packages with custom targets
@ -2329,3 +2347,2 @@doubles = {resolved = builtins.map lib.systems.from.string lib.systems.doubles.all;targets = {Is this name accurate? The previous made it clear that this was a collection of platform doubles (arch + os), but this one seems ambiguous.
the reason I elected to change it here was as once we add custom targets, they won't necessarily conform to arch+os. The change makes it more obvious that in order to get the double, you should
(lib.systems.withBuildInfo target).double@ -1754,3 +1767,3 @@value:letparts = lib.strings.split "-" value;value' =Let's avoid names using
'where possible. I find it mostly causes confusion.@ -33,3 +44,4 @@lib.systems = {match = builtins.mapAttrs (lib.fp.const matchAnyAttrs) lib.systems.patterns;extraTargets = config.systems.extraTargets;Why not have a set for
systems.targetsthat contains all of the defined targets and let users add to it directly?This one is tricky, as currently implemented, the user can enter a string parsable by
lib.systems.from.string, or an attrset with custom options like{ system = "x86_64-linux"; isStatic = true; linker = "mold"; }. The current list of targets is just a list of strings that is then converted intolib.systems.types.platformWithBuildInfo. If we exposed a list that the user appends to, they would need to do thelib.systems.withBuildInfoconversion manually on their side.Edit: Oh also this line specifically was just leftover from testing, getting rid of it
@ -13,2 +13,4 @@in{options = {dynamicLinker = lib.options.create {Thoughts on making this
linker? We probably also want to consider static linking as an option in the future.The original idea was to disambiguate between the compile time linker (tools like bfd
ld,mold, etc), and the systems dynamic linker loader (ld-linux-x86-64.so.2,libc.so, etc). Once we support alternative linkers there would probably be a naming collision0d8ad0c11btoe1ecf35f40wip: custom targetsto feat: custom targetsHydra is happy: https://hydra.aux-cache.dev/jobset/aux-prs/labs-pr42 (it only builds bash though as an example, I haven't figured out a sane way to evaluate and build the whole tidepool set!)
Looks good to me. Only concern I might have is the conflation of "target" and "target":
Hydra is still mostly happy, we need a rebase to pick up !53.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.