4J5GC67QDL4YO5PEF3FHLWGAIWBSHKZ4S3WG255ZRX4ZIB53534QC
let
# matches toolchain descriptions of type "nightly" or "nightly-2020-01-01"
channel_by_name = match "([a-z]+)(-([0-9]{4}-[0-9]{2}-[0-9]{2}))?.*" (readFile file);
# matches toolchain descriptions of type "1.34.0" or "1.34.0-2019-04-10"
channel_by_version = match "([0-9]+\\.[0-9]+\\.[0-9]+)(-([0-9]{4}-[0-9]{2}-[0-9]{2}))?.*" (readFile file);
in
(x: { channel = head x; date = (head (tail (tail x))); }) (
if channel_by_name != null then
channel_by_name
else
channel_by_version
);
let
# matches toolchain descriptions of type "nightly" or "nightly-2020-01-01"
channel_by_name =
match "([a-z]+)(-([0-9]{4}-[0-9]{2}-[0-9]{2}))?.*" (readFile file);
# matches toolchain descriptions of type "1.34.0" or "1.34.0-2019-04-10"
channel_by_version =
match "([0-9]+\\.[0-9]+\\.[0-9]+)(-([0-9]{4}-[0-9]{2}-[0-9]{2}))?.*"
(readFile file);
in (x: {
channel = head x;
date = (head (tail (tail x)));
})
(if channel_by_name != null then channel_by_name else channel_by_version);
rustToolchain ? null,
...
}:
let args = { inherit channel date; } // parseRustToolchain rustToolchain; in
let inherit (args) date channel; in
if date == null && staging == false
then "${dist_root}/channel-rust-${channel}"
else if date != null && staging == false
then "${dist_root}/${date}/channel-rust-${channel}"
else if date == null && staging == true
then "${dist_root}/staging/channel-rust-${channel}"
else throw "not a real-world case";
rustToolchain ? null, ... }:
let args = { inherit channel date; } // parseRustToolchain rustToolchain;
in let inherit (args) date channel;
in if date == null && staging == false then
"${dist_root}/channel-rust-${channel}"
else if date != null && staging == false then
"${dist_root}/${date}/channel-rust-${channel}"
else if date == null && staging == true then
"${dist_root}/staging/channel-rust-${channel}"
else
throw "not a real-world case";
srcInfo = pkg.target.${super.rust.toRustTarget stdenv.targetPlatform} or pkg.target."*";
components = srcInfo.components or [];
componentNamesList =
builtins.map (pkg: pkg.pkg) (builtins.filter (pkg: (pkg.target != "*")) components);
in
componentNamesList;
srcInfo = pkg.target.${
super.rust.toRustTarget stdenv.targetPlatform
} or pkg.target."*";
components = srcInfo.components or [ ];
componentNamesList = builtins.map (pkg: pkg.pkg)
(builtins.filter (pkg: (pkg.target != "*")) components);
in componentNamesList;
srcInfo = pkg.target.${super.rust.toRustTarget stdenv.targetPlatform} or pkg.target."*";
extensions = srcInfo.extensions or [];
srcInfo = pkg.target.${
super.rust.toRustTarget stdenv.targetPlatform
} or pkg.target."*";
extensions = srcInfo.extensions or [ ];
tuples = (getTuples pkgs pkgname pkgTargets) ++ (builtins.map (name: getTuples pkgs name compTargets) compExtIntersect);
in
tuples;
tuples = (getTuples pkgs pkgname pkgTargets)
++ (builtins.map (name: getTuples pkgs name compTargets)
compExtIntersect);
in tuples;
extensionsToInstall =
if missingExtensions == [] then extensions else throw ''
While compiling ${pkgname}: the extension ${head missingExtensions} is not available.
extensionsToInstall = if missingExtensions == [ ] then
extensions
else
throw ''
While compiling ${pkgname}: the extension ${
head missingExtensions
} is not available.
targetExtensionsToInstall = checkMissingExtensions pkgs pkgname stdenv targetExtensions;
extensionsToInstall = checkMissingExtensions pkgs pkgname stdenv extensions;
hostTargets = [ "*" (super.rust.toRustTarget stdenv.hostPlatform) (super.rust.toRustTarget stdenv.targetPlatform) ];
pkgTuples = flatten (getTargetPkgTuples pkgs pkgname hostTargets targets stdenv);
extensionTuples = flatten (map (name: getTargetPkgTuples pkgs name hostTargets targets stdenv) extensionsToInstall);
targetExtensionTuples = flatten (map (name: getTargetPkgTuples pkgs name targets targets stdenv) targetExtensionsToInstall);
targetExtensionsToInstall =
checkMissingExtensions pkgs pkgname stdenv targetExtensions;
extensionsToInstall =
checkMissingExtensions pkgs pkgname stdenv extensions;
hostTargets = [
"*"
(super.rust.toRustTarget stdenv.hostPlatform)
(super.rust.toRustTarget stdenv.targetPlatform)
];
pkgTuples =
flatten (getTargetPkgTuples pkgs pkgname hostTargets targets stdenv);
extensionTuples = flatten
(map (name: getTargetPkgTuples pkgs name hostTargets targets stdenv)
extensionsToInstall);
targetExtensionTuples = flatten
(map (name: getTargetPkgTuples pkgs name targets targets stdenv)
targetExtensionsToInstall);
missingTargets = subtractLists (map (tuple: tuple.target) pkgsTuples) (remove "*" targets);
pkgsTuplesToInstall =
if missingTargets == [] then pkgsTuples else throw ''
While compiling ${pkgname}: the target ${head missingTargets} is not available for any package.'';
in
map (tuple: { name = tuple.name; src = (getFetchUrl pkgs tuple.name tuple.target stdenv fetchurl); }) pkgsTuplesToInstall;
missingTargets = subtractLists (map (tuple: tuple.target) pkgsTuples)
(remove "*" targets);
pkgsTuplesToInstall = if missingTargets == [ ] then
pkgsTuples
else
throw "While compiling ${pkgname}: the target ${
head missingTargets
} is not available for any package.";
in map (tuple: {
name = tuple.name;
src = (getFetchUrl pkgs tuple.name tuple.target stdenv fetchurl);
}) pkgsTuplesToInstall;
version = "${elemAt version' 0}-${elemAt version' 2}-${elemAt version' 1}";
namesAndSrcs = getComponents pkgs.pkg name targets extensions targetExtensions stdenv fetchurl;
version =
"${elemAt version' 0}-${elemAt version' 2}-${elemAt version' 1}";
namesAndSrcs =
getComponents pkgs.pkg name targets extensions targetExtensions
stdenv fetchurl;
componentsOuts = builtins.map (comp: (super.lib.strings.escapeNixString (super.lib.getOutput "out" comp))) components;
in
super.pkgs.symlinkJoin {
name = name + "-" + version;
paths = components;
postBuild = ''
# If rustc or rustdoc is in the derivation, we need to copy their
# executable into the final derivation. This is required
# for making them find the correct SYSROOT.
for target in $out/bin/{rustc,rustdoc}; do
if [ -e $target ]; then
cp --remove-destination "$(realpath -e $target)" $target
fi
done
'';
componentsOuts = builtins.map (comp:
(super.lib.strings.escapeNixString
(super.lib.getOutput "out" comp))) components;
in super.pkgs.symlinkJoin {
name = name + "-" + version;
paths = components;
postBuild = ''
# If rustc or rustdoc is in the derivation, we need to copy their
# executable into the final derivation. This is required
# for making them find the correct SYSROOT.
for target in $out/bin/{rustc,rustdoc}; do
if [ -e $target ]; then
cp --remove-destination "$(realpath -e $target)" $target
fi
done
'';
# Add the compiler as part of the propagated build inputs in order
# to run:
#
# $ nix-shell -p rustChannels.stable.rust
#
# And get a fully working Rust compiler, with the stdenv linker.
propagatedBuildInputs = [ stdenv.cc ];
# Add the compiler as part of the propagated build inputs in order
# to run:
#
# $ nix-shell -p rustChannels.stable.rust
#
# And get a fully working Rust compiler, with the stdenv linker.
propagatedBuildInputs = [ stdenv.cc ];
fromManifest = sha256: manifest: { stdenv, fetchurl, patchelf }:
let manifestFile = if sha256 == null then builtins.fetchurl manifest else fetchurl { url = manifest; inherit sha256; };
fromManifest = sha256: manifest:
{ stdenv, fetchurl, patchelf }:
let
manifestFile = if sha256 == null then
builtins.fetchurl manifest
else
fetchurl {
url = manifest;
inherit sha256;
};
rustChannelOf = { sha256 ? null, ... } @ manifest_args: fromManifest
sha256 (manifest_v2_url manifest_args)
{ inherit (self) stdenv fetchurl patchelf; }
;
rustChannelOf = { sha256 ? null, ... }@manifest_args:
fromManifest sha256 (manifest_v2_url manifest_args) {
inherit (self) stdenv fetchurl patchelf;
};