nixpkgs/pkgs/development/compilers/dotnet/combine-deps.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

57 lines
1.2 KiB
Nix
Raw Normal View History

{
list,
baseRid,
otherRids,
2024-09-21 07:43:38 -04:00
pkgs ? import ../../../.. { },
}:
let
inherit (pkgs) writeText;
inherit (pkgs.lib)
concatMap
concatMapStringsSep
generators
optionals
replaceStrings
sortOn
strings
unique
;
fns = map (file: import file) list;
2024-09-21 07:43:38 -04:00
packages = unique (concatMap (fn: fn { fetchNuGet = package: package; }) fns);
2024-09-21 07:43:38 -04:00
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);
};
2024-09-21 07:43:38 -04:00
expandPackage =
package:
[ package ]
++ optionals (strings.match ".*\\.${baseRid}(\\..*|$)" package.pname != null) (
map (changePackageRid package) otherRids
);
2024-09-21 07:43:38 -04:00
allPackages = sortOn (package: [
package.pname
package.version
]) (concatMap expandPackage packages);
2024-09-21 07:43:38 -04:00
fetchExpr = package: " (fetchNuGet ${generators.toPretty { multiline = false; } package})";
2024-09-21 07:43:38 -04:00
in
writeText "deps.nix" ''
{ fetchNuGet }: [
${concatMapStringsSep "\n" fetchExpr allPackages}
]
''