Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ant.hook: init, migrate a few packages #357162

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

tomodachi94
Copy link
Member

@tomodachi94 tomodachi94 commented Nov 19, 2024

Add a setup hook for Ant.
It does a few different things; I recommend reading the documentation for a full explanation.

I also migrated a few packages to demonstrate that this works in practice. Since there are many packages that use Ant in Nixpkgs, it would be impractical to do all of them at once in this PR.

For maintainers of changed packages

I migrated your package to the new pattern. If something (e.g. an assumption about your package, or something with the hook) looks wrong, please let me know.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 25.05 Release Notes (or backporting 24.11 and 25.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@github-actions github-actions bot added the 8.has: documentation This PR adds or changes documentation label Nov 19, 2024
@tomodachi94 tomodachi94 force-pushed the enhance/ant/setup-hook branch 3 times, most recently from a1c058d to dd9f9cd Compare November 19, 2024 06:19
@tomodachi94 tomodachi94 added the 6.topic: java Including JDK, tooling, other languages, other VMs label Nov 19, 2024
@tomodachi94 tomodachi94 marked this pull request as ready for review November 19, 2024 06:36
@tomodachi94 tomodachi94 requested a review from a team November 19, 2024 06:38
@github-actions github-actions bot removed the 6.topic: java Including JDK, tooling, other languages, other VMs label Nov 19, 2024
@tomodachi94 tomodachi94 marked this pull request as draft November 19, 2024 15:47
@tomodachi94 tomodachi94 force-pushed the enhance/ant/setup-hook branch from dd9f9cd to 71a2599 Compare November 19, 2024 18:15
@tomodachi94
Copy link
Member Author

I removed the inline documentation to avoid duplicating content. A comment at the top of the hook now directs the user to the manual.

@tomodachi94 tomodachi94 marked this pull request as ready for review November 19, 2024 18:16
Copy link
Contributor

@TomaSajt TomaSajt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can break packages that have a call to ant inside of their build process.

e.g. the last time I encountered this situation was with rstudio, where cmake calls ant:

With this change, both cmake and ant try to override the buildPhase, and I guess ant's setup hook happens to get called earlier, thus the cmake build doesn't run. Also, since build.xml does not exist, it just errors out.

I guess we could just add dontUseAntBuild.

Personal opinion:
Hooks should not be directly included with the package they're wrapping.
I would be happier with an antHook than with ant having this default behaviour.
This would also not randomly break packages.

@tomodachi94
Copy link
Member Author

tomodachi94 commented Nov 19, 2024

This can break packages that have a call to ant inside of their build process.

Should I run nixpkgs-review on the changes and add dontUseAntBuild/dontUseAntCheck to builds that fail because of this change? Done, see below.

Hooks should not be directly included with the package they're wrapping.

Is there any consensus about whether we should include setup hooks in the packages themselves?

I'm conflicted: I agree that this can cause headaches when introducing a new hook into an existing package, but many packages do include a setup hook by default (like cmake).

@tomodachi94

This comment was marked as outdated.

@tomodachi94

This comment was marked as resolved.

@tomodachi94

This comment was marked as outdated.

@tomodachi94 tomodachi94 force-pushed the enhance/ant/setup-hook branch from 50f4758 to 105ed60 Compare November 20, 2024 00:04
@tomodachi94

This comment was marked as outdated.

@tomodachi94 tomodachi94 force-pushed the enhance/ant/setup-hook branch from 105ed60 to 3dabd15 Compare November 20, 2024 00:11
@tomodachi94 tomodachi94 changed the title ant: add setup hook, migrate a few packages ant: add setup hook, migrate a few packages, add exceptions Nov 20, 2024
@tomodachi94

This comment was marked as outdated.

@tomodachi94 tomodachi94 force-pushed the enhance/ant/setup-hook branch 2 times, most recently from efb88fa to a3a15e4 Compare November 20, 2024 03:46
@tomodachi94

This comment was marked as outdated.

@tomodachi94

This comment was marked as outdated.

@tomodachi94

This comment was marked as outdated.

@ofborg ofborg bot requested review from sikmir and bachp November 24, 2024 02:14
@tomodachi94 tomodachi94 requested a review from emilazy November 24, 2024 06:48
@tomodachi94 tomodachi94 removed the 1.severity: blocker This is preventing another PR or issue from being completed label Nov 26, 2024
@tomodachi94 tomodachi94 force-pushed the enhance/ant/setup-hook branch from d8a987f to 82aa5f9 Compare November 27, 2024 06:50
@github-actions github-actions bot added the 6.topic: java Including JDK, tooling, other languages, other VMs label Nov 27, 2024
@bjornfor
Copy link
Contributor

Result of nixpkgs-review pr 357162 run on x86_64-linux 1

1 package blacklisted:
  • nixos-install-tools
6 packages built:
  • jffi
  • jing
  • mkgmap-splitter
  • nixpkgs-manual
  • openrocket
  • xmloscopy

@tomodachi94 tomodachi94 added the 2.status: blocked by pr/issue Another PR or issue is preventing this from being completed label Nov 29, 2024
@tomodachi94

This comment was marked as outdated.

@philiptaron

This comment has been minimized.

@philiptaron philiptaron removed the 2.status: blocked by pr/issue Another PR or issue is preventing this from being completed label Nov 29, 2024
@tomodachi94 tomodachi94 force-pushed the enhance/ant/setup-hook branch from 82aa5f9 to d97495e Compare November 29, 2024 22:11
@TomaSajt
Copy link
Contributor

By the way, do we need to have ant be a wrapper?
Its only job is to add antFlags to all ant calls from bash.
But will we ever want to call ant manually while we're using the hook?
Maybe there's the rare situation where there are multiple different ant build.xml files, in that case yes, it would shave down a manual variable substitution.

But my personal opinion is that, if we're not inside the magical land of hooks anymore, we shouldn't try to override how commands work.

@tomodachi94 tomodachi94 force-pushed the enhance/ant/setup-hook branch from d97495e to c120ad8 Compare November 29, 2024 22:26
@tomodachi94 tomodachi94 force-pushed the enhance/ant/setup-hook branch from c120ad8 to fd71ebc Compare November 29, 2024 22:28
@tomodachi94
Copy link
Member Author

tomodachi94 commented Nov 29, 2024

By the way, do we need to have ant be a wrapper?

Not necessarily. The function is there to reduce the amount of copy-paste between phases; I'm not opposed to renaming it to _ant or something similar.

The wrapper can be circumvented. Per the docs:

https://github.com/tomodachi94/nixpkgs/blob/enhance/ant/setup-hook/doc/languages-frameworks/ant.section.md#L10-L17

@bjornfor
Copy link
Contributor

Maybe there's the rare situation where there are multiple different ant build.xml files, in that case yes, it would shave down a manual variable substitution.

We have that at $dayjob: build_{variantA,variantB}.xml.

@tomodachi94
Copy link
Member Author

tomodachi94 commented Nov 30, 2024

Ant itself also does that. In its GitHub repository, build.xml, check.xml, docs.xml, fetch.xml, and a handful more are present.

@wegank wegank added the 2.status: merge conflict This PR has merge conflicts with the target branch label Dec 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.status: merge conflict This PR has merge conflicts with the target branch 6.topic: continuous integration Affects continuous integration (CI) in Nixpkgs, including Ofborg and GitHub Actions 6.topic: java Including JDK, tooling, other languages, other VMs 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: changelog 8.has: documentation This PR adds or changes documentation 10.rebuild-darwin: 1-10 10.rebuild-linux: 1-10
Projects
Status: In progress
Development

Successfully merging this pull request may close these issues.

7 participants