2022-04-23 21:37:49 +00:00
|
|
|
/*
|
|
|
|
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.
|
|
|
|
*/
|
2023-01-29 07:18:21 +00:00
|
|
|
pkgs:
|
|
|
|
|
|
|
|
let
|
|
|
|
inherit (pkgs) lib;
|
|
|
|
inherit (lib)
|
2023-01-29 07:37:51 +00:00
|
|
|
all
|
2023-01-29 07:18:21 +00:00
|
|
|
flip
|
|
|
|
mapAttrs
|
2023-01-29 07:37:51 +00:00
|
|
|
mapAttrsToList
|
2023-01-29 07:18:21 +00:00
|
|
|
getAttrFromPath
|
|
|
|
importJSON
|
2022-04-23 21:37:49 +00:00
|
|
|
;
|
|
|
|
|
2023-01-29 07:54:13 +00:00
|
|
|
data = importJSON ./pkg-config-data.json;
|
2023-01-29 07:18:21 +00:00
|
|
|
inherit (data) modules;
|
|
|
|
|
2023-01-29 07:37:51 +00:00
|
|
|
platform = pkgs.stdenv.hostPlatform;
|
|
|
|
|
|
|
|
isSupported =
|
|
|
|
moduleData:
|
|
|
|
moduleData ? supportedWhenPlatformAttrsEqual
|
|
|
|
-> all (x: x) (
|
|
|
|
mapAttrsToList (
|
|
|
|
k: v: platform ? ${k} && platform.${k} == v
|
|
|
|
) moduleData.supportedWhenPlatformAttrsEqual
|
|
|
|
);
|
2024-12-10 19:26:33 +00:00
|
|
|
|
2023-01-29 07:18:21 +00:00
|
|
|
modulePkgs = flip mapAttrs modules (
|
|
|
|
_moduleName: moduleData:
|
2023-01-29 07:37:51 +00:00
|
|
|
if moduleData ? attrPath && isSupported moduleData then
|
2023-01-29 07:18:21 +00:00
|
|
|
getAttrFromPath moduleData.attrPath pkgs
|
|
|
|
else
|
|
|
|
null
|
|
|
|
);
|
|
|
|
|
|
|
|
in
|
2023-01-29 07:37:51 +00:00
|
|
|
modulePkgs
|