Skip to content

Commit

Permalink
eval: fallback to pkg.meta.position if unsafeGetAttrPos fails
Browse files Browse the repository at this point in the history
Fixes `nixpkgs.mpvScripts.*`, discovered while reviewing NixOS/nixpkgs#308062
  • Loading branch information
pbsds committed Apr 30, 2024
1 parent cafad8c commit 897330d
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions nix_update/eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,24 @@ def eval_expression(
return f"""
let
{indent(dedent(let_bindings), " ")}
positionFromMeta = pkg: let
inherit (builtins) fromJSON split elemAt length concatStringsSep;
parts = builtins.match "(.*):([0-9]+)" pkg.meta.position;
in if pkg ? meta.position then {{
file = elemAt parts 0;
line = fromJSON (elemAt parts 1);
}} else null;
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
sanitizePosition (builtins.unsafeGetAttrPos "src" pkg);
else if (builtins.unsafeGetAttrPos "src" pkg) != null then
sanitizePosition (builtins.unsafeGetAttrPos "src" pkg)
else
sanitizePosition (positionFromMeta pkg);
in {{
name = pkg.name;
old_version = pkg.version or (builtins.parseDrvName pkg.name).version;
Expand Down

0 comments on commit 897330d

Please sign in to comment.