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.

authored by tilpner and committed by Jörg Thalheim c610f99d 46427b77

+15 -21
+6 -1
pkgs/build-support/rust/default.nix
··· 1 - { stdenv, cacert, git, rust, rustRegistry }: 1 + { stdenv, callPackage, path, cacert, git, rust }: 2 2 { name, depsSha256 3 3 , src ? null 4 4 , srcs ? null ··· 8 8 , cargoUpdateHook ? "" 9 9 , cargoDepsHook ? "" 10 10 , cargoBuildFlags ? [] 11 + , registry ? null 11 12 , ... } @ args: 12 13 13 14 let 15 + lib = stdenv.lib; 16 + rustRegistry = callPackage (path + /pkgs/top-level/rust-packages.nix) 17 + (lib.optionalAttrs (registry != null) { src = registry; }); 18 + 14 19 fetchDeps = import ./fetchcargo.nix { 15 20 inherit stdenv cacert git rust rustRegistry; 16 21 };
-3
pkgs/top-level/all-packages.nix
··· 5795 5795 rustNightlyBin = lowPrio (callPackage ../development/compilers/rust/nightlyBin.nix { 5796 5796 buildRustPackage = callPackage ../build-support/rust { 5797 5797 rust = rustNightlyBin; 5798 - rustRegistry = callPackage ./rust-packages.nix { }; 5799 5798 }; 5800 5799 }); 5801 5800 ··· 5811 5810 callPackage = newScope self; 5812 5811 in { 5813 5812 inherit rust; 5814 - 5815 - rustRegistry = callPackage ./rust-packages.nix { }; 5816 5813 5817 5814 buildRustPackage = callPackage ../build-support/rust { 5818 5815 inherit rust;
+9 -17
pkgs/top-level/rust-packages.nix
··· 4 4 # version that we define here. If you're having problems downloading / finding 5 5 # a Rust library, try updating this to a newer commit. 6 6 7 - { runCommand, fetchFromGitHub, git }: 8 - 9 - let 10 - version = "2017-06-16"; 11 - rev = "cda0f689f844710a3d73c7ff459efa64997f73b5"; 12 - sha256 = "1b3brl9nn3qqaysd8lx9gaazd863grqx547iw7y9j6mkcc7sakvc"; 13 - 14 - src = fetchFromGitHub { 15 - inherit rev; 16 - inherit sha256; 17 - 18 - owner = "rust-lang"; 19 - repo = "crates.io-index"; 20 - }; 21 - 22 - in 7 + { runCommand, fetchFromGitHub, git 8 + , src ? fetchFromGitHub { 9 + owner = "rust-lang"; 10 + repo = "crates.io-index"; 11 + rev = "cda0f689f844710a3d73c7ff459efa64997f73b5"; 12 + sha256 = "1b3brl9nn3qqaysd8lx9gaazd863grqx547iw7y9j6mkcc7sakvc"; 13 + } 14 + }: 23 15 24 - runCommand "rustRegistry-${version}-${builtins.substring 0 7 rev}" { inherit src; } '' 16 + runCommand "rustRegistry" { inherit src; } '' 25 17 # For some reason, cargo doesn't like fetchgit's git repositories, not even 26 18 # if we set leaveDotGit to true, set the fetchgit branch to 'master' and clone 27 19 # the repository (tested with registry rev