nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1/*
2 A set of aliases to be used in generated expressions.
3
4 In case of ambiguity, this will pick a sensible default.
5
6 This was initially based on cabal2nix's mapping.
7
8 It'd be nice to generate this mapping, based on a set of derivations.
9 It can not be fully automated, so it should be a expression or tool
10 that makes suggestions about which pkg-config module names can be added.
11*/
12pkgs:
13
14let
15 inherit (pkgs) lib;
16 inherit (lib)
17 all
18 flip
19 mapAttrs
20 mapAttrsToList
21 getAttrFromPath
22 importJSON
23 ;
24
25 data = importJSON ./pkg-config-data.json;
26 inherit (data) modules;
27
28 platform = pkgs.stdenv.hostPlatform;
29
30 isSupported =
31 moduleData:
32 moduleData ? supportedWhenPlatformAttrsEqual
33 -> all (x: x) (
34 mapAttrsToList (
35 k: v: platform ? ${k} && platform.${k} == v
36 ) moduleData.supportedWhenPlatformAttrsEqual
37 );
38
39 modulePkgs = flip mapAttrs modules (
40 _moduleName: moduleData:
41 if moduleData ? attrPath && isSupported moduleData then
42 getAttrFromPath moduleData.attrPath pkgs
43 else
44 null
45 );
46
47in
48modulePkgs