2020-10-28 06:15:08 +00:00
|
|
|
{
|
2020-11-17 11:29:44 +00:00
|
|
|
condaChannelsExtra ? {},
|
2020-10-28 06:15:08 +00:00
|
|
|
pkgs ? import (import ./nixpkgs-src.nix) {},
|
2020-11-17 11:29:44 +00:00
|
|
|
providers ? builtins.fromJSON (builtins.readFile (builtins.getEnv "providers")),
|
2020-10-28 06:15:08 +00:00
|
|
|
system ? "x86_64-linux",
|
2020-11-17 11:29:44 +00:00
|
|
|
|
|
|
|
# conda-channels index
|
2020-10-28 06:15:08 +00:00
|
|
|
repoName ? "conda-channels",
|
|
|
|
repoOwner ? "DavHau",
|
2020-11-20 17:08:20 +00:00
|
|
|
condaDataRev ? (builtins.fromJSON (builtins.readFile ./CONDA_CHANNELS.json)).rev,
|
|
|
|
condaDataSha256 ? (builtins.fromJSON (builtins.readFile ./CONDA_CHANNELS.json)).indexSha256
|
2020-10-28 06:15:08 +00:00
|
|
|
}:
|
|
|
|
with builtins;
|
|
|
|
with pkgs.lib;
|
|
|
|
let
|
2020-11-17 11:29:44 +00:00
|
|
|
|
2020-10-28 06:15:08 +00:00
|
|
|
systemMap = {
|
|
|
|
x86_64-linux = "linux-64";
|
|
|
|
x86_64-darwin = "osx-64";
|
|
|
|
aarch64-linux = "linux-aarch64";
|
|
|
|
};
|
2020-11-17 11:29:44 +00:00
|
|
|
|
|
|
|
allProviders = flatten (attrValues providers);
|
|
|
|
|
|
|
|
usedChannels =
|
|
|
|
filter (p: p != null)
|
|
|
|
(map (p: if hasPrefix "conda/" p then removePrefix "conda/" p else null) allProviders);
|
|
|
|
|
|
|
|
channelRegistry = fromJSON (readFile (fetchurl {
|
2020-10-28 06:15:08 +00:00
|
|
|
name = "conda-channels-index";
|
2020-11-20 17:08:20 +00:00
|
|
|
url = "https://raw.githubusercontent.com/${repoOwner}/${repoName}/${condaDataRev}/sha256.json";
|
|
|
|
sha256 = condaDataSha256;
|
2020-10-28 06:15:08 +00:00
|
|
|
}));
|
2020-11-17 11:29:44 +00:00
|
|
|
|
|
|
|
registryChannels = mapAttrs' (filepath: hash:
|
|
|
|
let
|
|
|
|
split = splitString "/" filepath;
|
|
|
|
chan = elemAt split 1;
|
|
|
|
sys = removeSuffix ".json" (tail split);
|
|
|
|
in
|
|
|
|
nameValuePair
|
|
|
|
chan
|
|
|
|
(map (sys: (builtins.fetchurl {
|
2020-11-20 17:08:20 +00:00
|
|
|
url = "https://raw.githubusercontent.com/${repoOwner}/${repoName}/${condaDataRev}/${chan}/${sys}.json";
|
2020-11-17 11:29:44 +00:00
|
|
|
sha256 = channelRegistry."./${chan}/${sys}.json";
|
|
|
|
})) [ systemMap."${system}" "noarch" ])
|
|
|
|
) channelRegistry;
|
|
|
|
|
|
|
|
_registryChannels = filterAttrs (chan: json: elem chan usedChannels) registryChannels;
|
|
|
|
|
|
|
|
_condaChannelsExtra = filterAttrs (chan: json: elem chan usedChannels) condaChannelsExtra;
|
|
|
|
|
|
|
|
allCondaChannels = (_registryChannels // _condaChannelsExtra);
|
|
|
|
|
|
|
|
condaChannelsJson = pkgs.writeText "conda-channels.json" (toJSON allCondaChannels);
|
2020-11-18 18:09:56 +00:00
|
|
|
|
|
|
|
missingChannels = filter (c:
|
|
|
|
! elem c ((attrNames registryChannels) ++ (attrNames condaChannelsExtra))
|
|
|
|
) usedChannels;
|
|
|
|
|
2020-10-28 06:15:08 +00:00
|
|
|
in
|
2020-11-18 18:09:56 +00:00
|
|
|
if missingChannels != [] then
|
|
|
|
throw "Conda channels [${toString missingChannels}] are unknown. Use 'condaChannelsExtra' to make them available"
|
|
|
|
else
|
|
|
|
trace "using conda channels: ${toString (concatStringsSep ", " (attrNames allCondaChannels))}"
|
|
|
|
{ inherit condaChannelsJson; }
|