Skip to content

Commit

Permalink
ofborg/src/maintainers.nix: look up files pointed by "pos" attribute
Browse files Browse the repository at this point in the history
Sometimes most of attributes for a package are defined outside the file
that defines it. Examples are `openjdk` and `nix`.

At least `openjdk` defined `pos` attribute to guide `nix edit` to open
the right file. Let's extend `ofborg` to do the same.

Before the change (with `pos` applied to `nix_2_3`):

    $ printf '[["nix_2_3"]]' > attrs.json; \
      printf '["pkgs/tools/package-management/nix/default.nix"]' > paths.json; \
      nix-instantiate --eval maintainers.nix --arg changedattrsjson ./attrs.json --arg changedpathsjson ./paths.json
    { }

After the change:

    $ printf '[["nix_2_3"]]' > attrs.json; \
      printf '["pkgs/tools/package-management/nix/default.nix"]' > paths.json; \
      nix-instantiate --eval maintainers.nix --arg changedattrsjson ./attrs.json --arg changedpathsjson ./paths.json
    { flokli = <CODE>; raitobezarius = <CODE>; }
  • Loading branch information
trofi authored and cole-h committed Jan 16, 2024
1 parent de415d3 commit 7db074d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions ofborg/src/maintainers.nix
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,17 @@ let
#(builtins.unsafeGetAttrPos "name" drv)
(builtins.unsafeGetAttrPos "pname" drv)
(builtins.unsafeGetAttrPos "version" drv)

# Use ".meta.position" for cases when most of the package is
# defined in a "common" section and the only place where
# reference to the file with a derivation the "pos"
# attribute.
#
# ".meta.position" has the following form:
# "pkgs/tools/package-management/nix/default.nix:155"
# We transform it to the following:
# { file = "pkgs/tools/package-management/nix/default.nix"; }
{ file = pkgs.lib.head (pkgs.lib.splitString ":" (drv.meta.position or "")); }
]
)));

Expand Down

0 comments on commit 7db074d

Please sign in to comment.