Try pkg.meta.position before unsafeGetAttrPos

Fixes `nixpkgs.mpvScripts.*`, discovered while reviewing https://github.com/NixOS/nixpkgs/pull/308062
This commit is contained in:
Peder Bergebakken Sundt 2024-04-30 23:04:10 +02:00 committed by mergify[bot]
parent cafad8ced8
commit 63b5a4e989

View File

@ -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);
in {{
name = pkg.name;