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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions nix_update/eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 {{
file = builtins.elemAt parts 0;
line = builtins.fromJSON (builtins.elemAt parts 1);
}};

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

position = if pkg ? isRubyGem then
position = if pkg ? meta.position then
sanitizePosition (positionFromMeta pkg)
else if pkg ? isRubyGem then
raw_version_position
else if pkg ? isPhpExtension then
raw_version_position
else
else
sanitizePosition (builtins.unsafeGetAttrPos "src" pkg);
Copy link
Contributor

Choose a reason for hiding this comment

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

Indeed if it is possible to set meta.position, this nix-update PR here makes a bit more sense. However, since mkDerivation always sets meta.position, the pkg.src attribute will never be retrieved here. Or perhaps it will be retrieved for other derivation builders? I doubt if there are builders that are not based on mkDerivation for which it will happen.

in {{
name = pkg.name;
Expand Down