depot/third_party/nixpkgs/pkgs/development/compilers/dotnet/combine-deps.nix
Default email 587713944a Project import generated by Copybara.
GitOrigin-RevId: 6143fc5eeb9c4f00163267708e26191d1e918932
2024-04-21 17:54:59 +02:00

51 lines
1.1 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}
]
''