1{
2 list,
3 baseRid,
4 otherRids,
5 pkgs ? import ../../../.. { },
6}:
7let
8 inherit (pkgs) writeText;
9
10 inherit (pkgs.lib)
11 concatMap
12 concatMapStringsSep
13 generators
14 importJSON
15 optionals
16 replaceStrings
17 sortOn
18 strings
19 unique
20 ;
21
22 packages = concatMap (file: importJSON file) list;
23
24 changePackageRid =
25 package: rid:
26 let
27 replace = replaceStrings [ ".${baseRid}" ] [ ".${rid}" ];
28 in
29 rec {
30 pname = replace package.pname;
31 inherit (package) version;
32 url = replace package.url;
33 sha256 = builtins.hashFile "sha256" (builtins.fetchurl url);
34 };
35
36 expandPackage =
37 package:
38 [ package ]
39 ++ optionals (strings.match ".*\\.${baseRid}(\\..*|$)" package.pname != null) (
40 map (changePackageRid package) otherRids
41 );
42
43 allPackages = sortOn (package: [
44 package.pname
45 package.version
46 ]) (concatMap expandPackage packages);
47
48in
49writeText "deps.json" (builtins.toJSON allPackages)