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

Tracking pkg-config provides #295047

Closed
Ericson2314 opened this issue Jan 13, 2023 · 7 comments
Closed

Tracking pkg-config provides #295047

Ericson2314 opened this issue Jan 13, 2023 · 7 comments
Labels
6.topic: architecture Relating to code and API architecture of Nixpkgs

Comments

@Ericson2314
Copy link
Member

Ericson2314 commented Jan 13, 2023

Issue description

The world really needs to know which distro package provides which pkg-config package. This is important because pkg-config package names are the defacto way to refer to C / "foreign" libraries in a distro-agnostic way, and we generally want upstream package managers to use them vs more ad-hoc methods.

This would be really good for upstream language-based tools, our lang2nix tools, really everybody.

In repology/repology-updater#1309, the Repology maintainer @AMDmi3 has kindly offered:

If you propose to publish pkgconfig names for nix[pkgs] (and I suppose use these to map pkgconfig files to package names for all other repos), that should be easy to implement in repology.

That sounds amazing!

Goal

We should have

  1. Something like a meta.pkg-config field, which is either a single string or list of strings
  2. Some sort of setup hook or separate test derivation that verifies the package, when built, indeed provides this pkg-config .pc file.

CC @dcbaker

@Ericson2314
Copy link
Member Author

CC @hamishmack and @sternenseemann, as I imagine both Haskell infrastructures have a pretty good list initial list we could use to get started on this.

@sternenseemann
Copy link
Member

We have a lookup table, but it is very aggressive: It maps names to nixpkgs attribute paths, but those names may either be the name you'd pass to pkg-config or the name you'd pass to the linker via -l. Consequently, the data would need quite a bit of manual cleaning up. For the curious libNixName in Distribution.Nixpkgs.Haskell.FromCabal.Name in cabal2nix'

@Artturin
Copy link
Member

nix-index can be used to find all the pc files

nix-locate --regex --top-level '/lib/pkgconfig/.*.pc'

The output format is

abseil-cpp.out                                      502 r /nix/store/wsi5wc7qhmix5f6aiz6p1yyhnhcwrdrp-abseil-cpp-20210324.2/lib/pkgconfig/absl_wyhash.pc

@grahamc
Copy link
Member

grahamc commented Jan 24, 2023

@Ericson2314 pinged me because of our work on Riff.sh. We looked at doing something similar back in September, but never took steps on it. Maybe this is useful info:

Investigate indexing pkg-config files

go.mod allows listing pkg-config packages

cgo directives also allow listing pkg-config packages

It would be useful to be able to look up nix packages by pkg-config name.

We could probably generate an index mapping pkg-config package names to nixpkgs attr names from a nix-index database, and plonk that into the registry. See how feasible this is, how much data comes out, etc.

We were planning on doing it through something like nix-index instead of adding metadata preemptively to Nixpkgs. But I think either way could work.

@Ericson2314
Copy link
Member Author

And I was totally unaware that Go leverages this too! Good to see more newer languages going with pkg-config out of the box.

@Ericson2314
Copy link
Member Author

Ericson2314 commented Feb 3, 2023

#214304

@Ericson2314
Copy link
Member Author

That is merged so this is done! Just need to go annotate all the packages now :)

@infinisil infinisil transferred this issue from nixpkgs-architecture/issues Mar 11, 2024
@infinisil infinisil added the 6.topic: architecture Relating to code and API architecture of Nixpkgs label Mar 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: architecture Relating to code and API architecture of Nixpkgs
Projects
None yet
Development

No branches or pull requests

5 participants