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

Try pkg.meta.position before unsafeGetAttrPos #247

Merged
merged 1 commit into from
May 8, 2024

Conversation

pbsds
Copy link
Contributor

@pbsds pbsds commented Apr 30, 2024

Some package builders set meta.position manually due to clobbering the origin of src.

Fixes nix-update -u mpvScripts.*, discovered while reviewing NixOS/nixpkgs#308062.

@pbsds pbsds force-pushed the use-meta-position branch 2 times, most recently from e2d9ad0 to 1aede84 Compare May 4, 2024 15:11
else if (builtins.unsafeGetAttrPos "src" pkg) != null then
sanitizePosition (builtins.unsafeGetAttrPos "src" pkg)
else
sanitizePosition (positionFromMeta pkg);
Copy link
Owner

Choose a reason for hiding this comment

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

If we have meta.position, should it not be preferred over src?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i was trying to change as little of existing behaviour as possible, by if you're on board with this change then why not.

@pbsds pbsds changed the title Fallback to pkg.meta.position if unsafeGetAttrPos returns null Try pkg.meta.position before (unsafeGetAttrPos "src" pkg) May 6, 2024
@@ -142,13 +142,22 @@ def eval_expression(
return f"""
let
{indent(dedent(let_bindings), " ")}
positionFromMeta = pkg: let
parts = builtins.match "(.*):([0-9]+)" pkg.meta.position;
in if pkg ? meta.position then {{
Copy link
Owner

Choose a reason for hiding this comment

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

Do we need this if here? It's already checked on line 158. Also would make the code slightly simpler.

raw_version_position = sanitizePosition (builtins.unsafeGetAttrPos "version" pkg);

position = if pkg ? isRubyGem then
raw_version_position
else if pkg ? isPhpExtension then
raw_version_position
else
else if pkg ? meta.position then
sanitizePosition (positionFromMeta pkg)
Copy link
Owner

Choose a reason for hiding this comment

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

I think we can even overrule the quirks for ruby gems and php here, I would say.

@pbsds pbsds changed the title Try pkg.meta.position before (unsafeGetAttrPos "src" pkg) Try pkg.meta.position before unsafeGetAttrPos May 8, 2024
Fixes `nixpkgs.mpvScripts.*`, discovered while reviewing NixOS/nixpkgs#308062
@Mic92
Copy link
Owner

Mic92 commented May 8, 2024

@mergify queue

Copy link
Contributor

mergify bot commented May 8, 2024

queue

✅ The pull request has been merged automatically

The pull request has been merged automatically at 63b5a4e

@mergify mergify bot merged commit 63b5a4e into Mic92:master May 8, 2024
4 checks passed
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.

None yet

2 participants