Expose custom Rust registry versions

This allows users to specify a custom registry src,
because currently every packager would need to create
an outdated Cargo.lock just to be compatible with the
probably outdated rustRegistry in nixpkgs.

Currently there is no easy way to convince cargo to
do that, so this makes that workaround unnecessary.
This commit is contained in:
tilpner 2017-06-14 23:36:27 +02:00 committed by Jörg Thalheim
parent 46427b77f4
commit c610f99d8f
3 changed files with 15 additions and 21 deletions

View file

@ -1,4 +1,4 @@
{ stdenv, cacert, git, rust, rustRegistry }:
{ stdenv, callPackage, path, cacert, git, rust }:
{ name, depsSha256
, src ? null
, srcs ? null
@ -8,9 +8,14 @@
, cargoUpdateHook ? ""
, cargoDepsHook ? ""
, cargoBuildFlags ? []
, registry ? null
, ... } @ args:
let
lib = stdenv.lib;
rustRegistry = callPackage (path + /pkgs/top-level/rust-packages.nix)
(lib.optionalAttrs (registry != null) { src = registry; });
fetchDeps = import ./fetchcargo.nix {
inherit stdenv cacert git rust rustRegistry;
};

View file

@ -5795,7 +5795,6 @@ with pkgs;
rustNightlyBin = lowPrio (callPackage ../development/compilers/rust/nightlyBin.nix {
buildRustPackage = callPackage ../build-support/rust {
rust = rustNightlyBin;
rustRegistry = callPackage ./rust-packages.nix { };
};
});
@ -5812,8 +5811,6 @@ with pkgs;
in {
inherit rust;
rustRegistry = callPackage ./rust-packages.nix { };
buildRustPackage = callPackage ../build-support/rust {
inherit rust;
};

View file

@ -4,24 +4,16 @@
# version that we define here. If you're having problems downloading / finding
# a Rust library, try updating this to a newer commit.
{ runCommand, fetchFromGitHub, git }:
{ runCommand, fetchFromGitHub, git
, src ? fetchFromGitHub {
owner = "rust-lang";
repo = "crates.io-index";
rev = "cda0f689f844710a3d73c7ff459efa64997f73b5";
sha256 = "1b3brl9nn3qqaysd8lx9gaazd863grqx547iw7y9j6mkcc7sakvc";
}
}:
let
version = "2017-06-16";
rev = "cda0f689f844710a3d73c7ff459efa64997f73b5";
sha256 = "1b3brl9nn3qqaysd8lx9gaazd863grqx547iw7y9j6mkcc7sakvc";
src = fetchFromGitHub {
inherit rev;
inherit sha256;
owner = "rust-lang";
repo = "crates.io-index";
};
in
runCommand "rustRegistry-${version}-${builtins.substring 0 7 rev}" { inherit src; } ''
runCommand "rustRegistry" { inherit src; } ''
# For some reason, cargo doesn't like fetchgit's git repositories, not even
# if we set leaveDotGit to true, set the fetchgit branch to 'master' and clone
# the repository (tested with registry rev