depot/pkgs/development/compilers/dotnet/combine-deps.nix
Luke Granger-Brown 57725ef3ec Squashed 'third_party/nixpkgs/' content from commit 76612b17c0ce
git-subtree-dir: third_party/nixpkgs
git-subtree-split: 76612b17c0ce71689921ca12d9ffdc9c23ce40b2
2024-11-10 23:59:47 +00:00

56 lines
1.2 KiB
Nix

{
list,
baseRid,
otherRids,
pkgs ? import ../../../.. { },
}:
let
inherit (pkgs) writeText;
inherit (pkgs.lib)
concatMap
concatMapStringsSep
generators
optionals
replaceStrings
sortOn
strings
unique
;
fns = map (file: import file) list;
packages = unique (concatMap (fn: fn { fetchNuGet = package: package; }) fns);
changePackageRid =
package: rid:
let
replace = replaceStrings [ ".${baseRid}" ] [ ".${rid}" ];
in
rec {
pname = replace package.pname;
inherit (package) version;
url = replace package.url;
sha256 = builtins.hashFile "sha256" (builtins.fetchurl url);
};
expandPackage =
package:
[ package ]
++ optionals (strings.match ".*\\.${baseRid}(\\..*|$)" package.pname != null) (
map (changePackageRid package) otherRids
);
allPackages = sortOn (package: [
package.pname
package.version
]) (concatMap expandPackage packages);
fetchExpr = package: " (fetchNuGet ${generators.toPretty { multiline = false; } package})";
in
writeText "deps.nix" ''
{ fetchNuGet }: [
${concatMapStringsSep "\n" fetchExpr allPackages}
]
''