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

trivial: make symlinkJoin support pname+version alone #344645

Merged
merged 2 commits into from
Oct 23, 2024

Conversation

pbsds
Copy link
Member

@pbsds pbsds commented Sep 26, 2024

Description of changes

inspired by Mic92/nix-update#284

should be 0 rebuilds

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/)
  • 24.11 Release Notes (or backporting 23.11 and 24.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.

@pbsds pbsds marked this pull request as ready for review September 26, 2024 12:56
@pbsds pbsds requested a review from philiptaron as a code owner September 26, 2024 12:56
@pbsds pbsds force-pushed the feat-pname-symlinkjoin-1727354748 branch from 2a88cec to cb93e64 Compare September 26, 2024 13:02
@github-actions github-actions bot added the 8.has: documentation This PR adds or changes documentation label Sep 26, 2024
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 10.rebuild-linux: 1 labels Sep 26, 2024
Copy link
Contributor

@drupol drupol left a comment

Choose a reason for hiding this comment

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

LGTM but I'd wait for another review.

@pbsds pbsds force-pushed the feat-pname-symlinkjoin-1727354748 branch from cb93e64 to 290677b Compare September 26, 2024 23:21
Copy link
Contributor

@philiptaron philiptaron left a comment

Choose a reason for hiding this comment

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

Yeah, this is fine. We could finesse it a little:

  1. Better error message if nothing is specified.
  2. Better error message if name AND pname || version is specified
  3. Better error message if pname but not version is specified and vice versa
  4. Don't pass through the pname or version into runCommand's derivationArgs (name already omitted)

Copy link
Member

@getchoo getchoo left a comment

Choose a reason for hiding this comment

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

+1 on the errors mention by Philip, but the removal of pname and version here is a requirement IMO

@pbsds pbsds force-pushed the feat-pname-symlinkjoin-1727354748 branch from 290677b to 169d2c6 Compare September 27, 2024 23:35
@pbsds
Copy link
Member Author

pbsds commented Sep 27, 2024

  1. Better error message if nothing is specified.

Done

  1. Better error message if name AND pname || version is specified

This is not an error in mkDerivation

  1. Better error message if pname but not version is specified and vice versa

1 already partially covers this. Handling this request in full is possible, but I'm not sure if I like it:

assert lib.assertMsg (args_ ? pname && args_ ? version)
  "symlinkJoin requires either a `name` OR `pname` and `version`, found: ${lib.concatStringsSep ", " (lib.filter (lib.flip builtins.elem ["name" "pname" "version"]) (lib.attrNames args_))}";
"${args_.pname}-${args_.version}"
  1. Don't pass through the pname or version into runCommand's derivationArgs (name already omitted)

That would mean not setting finalPackage.pname and finalPackage.version, which is the current behaviour and the entire reason why you want to provide these args

@pbsds
Copy link
Member Author

pbsds commented Sep 27, 2024

+1 on the errors mention by Philip, but the removal of pname and version here is a requirement IMO

This confuses me, is there a negation missing or is there something i'm missing?

@philiptaron
Copy link
Contributor

Handling this request in full is possible, but I'm not sure if I like it.

Here's my attempt, designed to be placed after in the let block.

assert lib.assertMsg (args_ ? name -> !(args ? pname || args ? version) "symlinkJoin requires either `name` or `pname` and `version`; to fix this, remove `name` or both of `pname` and `version`"
assert lib.assertMsg (args_ ? pname == args_ ? version) "symlinkJoin requires `pname` and `version` to be specified together";

@philiptaron
Copy link
Contributor

This confuses me, is there a negation missing or is there something I'm missing?

No, I think I'm the source of the issue: I didn't fully understand that getting pname and especially version into the resulting derivationArgs was a key goal of this patch.

@pbsds pbsds marked this pull request as draft September 28, 2024 00:50
@pbsds
Copy link
Member Author

pbsds commented Sep 28, 2024

It does seem to achieve the intended hardening (2 and 3), but the breakage is massive and I assume the eval times will increase, especially in nixos.

@pbsds
Copy link
Member Author

pbsds commented Sep 28, 2024

Drafted until the way forward is decided. Do we (1) forge ahead and establish this new hardening convention and patch all violations, or (2) drop 42ab48f ?

@philiptaron
Copy link
Contributor

Drafted until the way forward is decided. Do we (1) forge ahead and establish this new hardening convention and patch all violations, or (2) drop 42ab48f ?

Note the performance result: https://github.com/NixOS/nixpkgs/pull/344645/checks?check_run_id=30790294683

For me, given that there's any eval troubles, I'm more on the drop-and-defer-to-a-future-PR train -- a PR that means to tackle this relatively common idiom of name vs. pname/version, and that makes a stand about how it ought to be represented in nixpkgs.

@philiptaron
Copy link
Contributor

I'm still on the drop-and-defer-to-a-future-PR train. 🚋

@pbsds
Copy link
Member Author

pbsds commented Oct 11, 2024

oh wow it has been two weeks. I was supposed to revert the commit but forgot

@pbsds
Copy link
Member Author

pbsds commented Oct 11, 2024

pr is stuck at "processing" after I pushed, might be the current outage https://www.githubstatus.com/incidents/myvz2tsj2dh8

@philiptaron
Copy link
Contributor

I don't think the relevant commit was dropped.

@pbsds
Copy link
Member Author

pbsds commented Oct 11, 2024

image

@philiptaron
Copy link
Contributor

image

Dang, I think my eyes have never processed that section of the header before. 👀 Thanks for entertaining my blindness. 😁

@pbsds pbsds force-pushed the feat-pname-symlinkjoin-1727354748 branch from 169d2c6 to 0eb7e09 Compare October 12, 2024 18:41
@pbsds pbsds marked this pull request as ready for review October 12, 2024 18:41
@philiptaron philiptaron merged commit eee954a into NixOS:master Oct 23, 2024
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8.has: clean-up 8.has: documentation This PR adds or changes documentation 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 10.rebuild-linux: 1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants