From 09eb09b9c50d4f44082a7843b1222bfbaa2d7887 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Sun, 29 Jan 2023 08:37:51 +0100 Subject: [PATCH] pkg-config-data.json: Encode platform support --- pkgs/top-level/pkg-config-packages.nix | 29 +++++++------ .../top-level/pkg-config/pkg-config-data.json | 42 +++++++++++++++---- 2 files changed, 48 insertions(+), 23 deletions(-) diff --git a/pkgs/top-level/pkg-config-packages.nix b/pkgs/top-level/pkg-config-packages.nix index 8d428cfb2182..b5cda4939156 100644 --- a/pkgs/top-level/pkg-config-packages.nix +++ b/pkgs/top-level/pkg-config-packages.nix @@ -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 diff --git a/pkgs/top-level/pkg-config/pkg-config-data.json b/pkgs/top-level/pkg-config/pkg-config-data.json index 55036d91fce8..c0b6e49b48a0 100644 --- a/pkgs/top-level/pkg-config/pkg-config-data.json +++ b/pkgs/top-level/pkg-config/pkg-config-data.json @@ -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": [