pkg-config-data.json: Encode platform support

This commit is contained in:
Robert Hensing 2023-01-29 08:37:51 +01:00
parent 81a541e6b6
commit 09eb09b9c5
2 changed files with 48 additions and 23 deletions

View File

@ -13,34 +13,33 @@ pkgs:
let
inherit (pkgs) lib;
inherit (lib)
all
flip
mapAttrs
mapAttrsToList
getAttrFromPath
importJSON
;
result = modulePkgs // overrides;
data = importJSON ./pkg-config/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 then
if moduleData?attrPath && isSupported moduleData then
getAttrFromPath moduleData.attrPath pkgs
else
null
);
overrides = {
hidapi = if pkgs.stdenv.isDarwin then pkgs.hidapi else null;
hidapi-hidraw = if pkgs.stdenv.isDarwin then null else pkgs.hidapi;
hidapi-libusb = if pkgs.stdenv.isDarwin then null else pkgs.hidapi;
libpulse-mainloop-glib = if pkgs.stdenv.isDarwin then null else pkgs.libpulseaudio;
wayland-client = if pkgs.stdenv.isDarwin then null else pkgs.wayland;
wayland-cursor = if pkgs.stdenv.isDarwin then null else pkgs.wayland;
egl = if pkgs.stdenv.isDarwin then null else pkgs.libGL;
wayland-server = if pkgs.stdenv.isDarwin then null else pkgs.wayland;
};
in
result
modulePkgs

View File

@ -180,7 +180,10 @@
"egl": {
"attrPath": [
"libGL"
]
],
"supportedWhenPlatformAttrsEqual": {
"isDarwin": false
}
},
"fftw3": {
"attrPath": [
@ -350,17 +353,28 @@
]
},
"hidapi": {
"attrPath": null
"attrPath": [
"hidapi"
],
"supportedWhenPlatformAttrsEqual": {
"isDarwin": true
}
},
"hidapi-hidraw": {
"attrPath": [
"hidapi"
]
],
"supportedWhenPlatformAttrsEqual": {
"isDarwin": false
}
},
"hidapi-libusb": {
"attrPath": [
"hidapi"
]
],
"supportedWhenPlatformAttrsEqual": {
"isDarwin": false
}
},
"icu-i18n": {
"attrPath": [
@ -525,7 +539,10 @@
"libpulse-mainloop-glib": {
"attrPath": [
"libpulseaudio"
]
],
"supportedWhenPlatformAttrsEqual": {
"isDarwin": false
}
},
"libpulse-simple": {
"attrPath": [
@ -811,12 +828,18 @@
"wayland-client": {
"attrPath": [
"wayland"
]
],
"supportedWhenPlatformAttrsEqual": {
"isDarwin": false
}
},
"wayland-cursor": {
"attrPath": [
"wayland"
]
],
"supportedWhenPlatformAttrsEqual": {
"isDarwin": false
}
},
"wayland-scanner": {
"attrPath": [
@ -826,7 +849,10 @@
"wayland-server": {
"attrPath": [
"wayland"
]
],
"supportedWhenPlatformAttrsEqual": {
"isDarwin": false
}
},
"webkit2gtk-4.0": {
"attrPath": [