From c610f99d8fc25dbdcd8530aca17a838c32ac569f Mon Sep 17 00:00:00 2001 From: tilpner Date: Wed, 14 Jun 2017 23:36:27 +0200 Subject: [PATCH] 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. --- pkgs/build-support/rust/default.nix | 7 ++++++- pkgs/top-level/all-packages.nix | 3 --- pkgs/top-level/rust-packages.nix | 26 +++++++++----------------- 3 files changed, 15 insertions(+), 21 deletions(-) diff --git a/pkgs/build-support/rust/default.nix b/pkgs/build-support/rust/default.nix index 2275a065594f..6e2c44552252 100644 --- a/pkgs/build-support/rust/default.nix +++ b/pkgs/build-support/rust/default.nix @@ -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; }; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 18d1b4a6e3c2..d7a34f55f7a2 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -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; }; diff --git a/pkgs/top-level/rust-packages.nix b/pkgs/top-level/rust-packages.nix index 45e4d8e812e7..67351b7bec0a 100644 --- a/pkgs/top-level/rust-packages.nix +++ b/pkgs/top-level/rust-packages.nix @@ -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