depot/third_party/nixpkgs/pkgs/top-level/pkg-config/defaultPkgConfigPackages.nix
Default email a0cb138ada Project import generated by Copybara.
GitOrigin-RevId: a100acd7bbf105915b0004427802286c37738fef
2023-02-02 18:25:31 +00:00

45 lines
1.1 KiB
Nix

/* A set of aliases to be used in generated expressions.
In case of ambiguity, this will pick a sensible default.
This was initially based on cabal2nix's mapping.
It'd be nice to generate this mapping, based on a set of derivations.
It can not be fully automated, so it should be a expression or tool
that makes suggestions about which pkg-config module names can be added.
*/
pkgs:
let
inherit (pkgs) lib;
inherit (lib)
all
flip
mapAttrs
mapAttrsToList
getAttrFromPath
importJSON
;
data = importJSON ./pkg-config-data.json;
inherit (data) modules;
platform = pkgs.stdenv.hostPlatform;
isSupported = moduleData:
moduleData?supportedWhenPlatformAttrsEqual ->
all (x: x) (
mapAttrsToList
(k: v: platform?${k} && platform.${k} == v)
moduleData.supportedWhenPlatformAttrsEqual
);
modulePkgs = flip mapAttrs modules (_moduleName: moduleData:
if moduleData?attrPath && isSupported moduleData then
getAttrFromPath moduleData.attrPath pkgs
else
null
);
in
modulePkgs