diff --git a/doc/languages-frameworks/rust.section.md b/doc/languages-frameworks/rust.section.md
index 6588281878a0..737759fd8bd8 100644
--- a/doc/languages-frameworks/rust.section.md
+++ b/doc/languages-frameworks/rust.section.md
@@ -42,7 +42,8 @@ rustPlatform.buildRustPackage rec {
     sha256 = "0y5d1n6hkw85jb3rblcxqas2fp82h3nghssa4xqrhqnz25l799pj";
   };
 
-  cargoSha256 = "0q68qyl2h6i0qsz82z840myxlnjay8p1w5z7hfyr8fqp7wgwa9cx";
+  cargoSha256 = "194lzn9xjkc041lmqnm676ydgbhn45xx9jhrhz6lzlg99yr6b880";
+  useRealVendorConfig = true;
 
   meta = with stdenv.lib; {
     description = "A fast line-oriented regex search tool, similar to ag and ack";
@@ -64,6 +65,14 @@ When the `Cargo.lock`, provided by upstream, is not in sync with the
 added in `cargoPatches` will also be prepended to the patches in `patches` at
 build-time.
 
+The `useRealVendorConfig` parameter tells cargo-vendor to include a Cargo
+configuration file in the fetched dependencies. This will fix problems with
+projects, where Crates are downloaded from non-crates.io sources. Please note,
+that currently this parameter defaults to `false` only due to compatibility
+reasons, as setting this to `true` requires a change in `cargoSha256`.
+Eventually this distinction will be deprecated, so please always set
+`useRealVendorConfig` to `true` and make sure to recompute the `cargoSha256`.
+
 To install crates with nix there is also an experimental project called
 [nixcrates](https://github.com/fractalide/nixcrates).
 
diff --git a/nixos/doc/manual/release-notes/rl-1809.xml b/nixos/doc/manual/release-notes/rl-1809.xml
index 01421fc5dda7..dd04996925bb 100644
--- a/nixos/doc/manual/release-notes/rl-1809.xml
+++ b/nixos/doc/manual/release-notes/rl-1809.xml
@@ -551,6 +551,27 @@ inherit (pkgs.nixos {
       <literal>stdenv.buildPlatform</literal>, <literal>stdenv.hostPlatform</literal>, and <literal>stdenv.targetPlatform</literal>.
     </para>
   </listitem>
+  <listitem>
+    <para>
+	    The <literal>buildRustPackage</literal> function got the new
+	    argument <literal>useRealVendorConfig</literal>, currently
+	    defaulting to <literal>false</literal>. Setting it to
+	    <literal>true</literal> necessates the recomputation of the
+	    <literal>cargoSha256</literal> and fixes a problem with
+	    dependencies, that were fetched from a non-crates.io source.
+	    Eventually only the <literal>true</literal> behaviour will be kept,
+	    so please set it explicitly to <literal>true</literal> and
+	    recompute your <literal>cargoSha256</literal>, so that we can
+	    migrate to the new behaviour and deprecate the option.
+    </para>
+    <para>
+	    While recomputing <literal>cargoSha256</literal>, it is important
+	    to first invalidate the hash (e.g. by changing a digit), so that
+	    Nix actually rebuilds the fixed-output derivation. Otherwise this
+	    could lead to hard to detect errors, where a package seemingly
+	    builds on your computer, but breaks on others!
+    </para>
+  </listitem>
   </itemizedlist>
  </section>
 </section>
diff --git a/pkgs/build-support/rust/default.nix b/pkgs/build-support/rust/default.nix
index 820989a76206..a2dc5df4d926 100644
--- a/pkgs/build-support/rust/default.nix
+++ b/pkgs/build-support/rust/default.nix
@@ -17,9 +17,15 @@ in
 , cargoBuildFlags ? []
 
 , cargoVendorDir ? null
+# This tells cargo-vendor to include a Cargo config file in the fixed-output
+# derivation. This is desirable in every case, so please set it to true.
+# Eventually this will default to true and even later this option and the old
+# behaviour will be removed.
+, useRealVendorConfig ? false
 , ... } @ args:
 
 assert cargoVendorDir == null -> cargoSha256 != "unset";
+assert cargoVendorDir != null -> !useRealVendorConfig;
 
 let
   cargoDeps = if cargoVendorDir == null
@@ -27,6 +33,7 @@ let
         inherit name src srcs sourceRoot cargoUpdateHook;
         patches = cargoPatches;
         sha256 = cargoSha256;
+        writeVendorConfig = useRealVendorConfig;
       }
     else null;
 
@@ -61,14 +68,19 @@ in stdenv.mkDerivation (args // {
     ${setupVendorDir}
 
     mkdir .cargo
-    cat >.cargo/config <<-EOF
-      [source.crates-io]
-      registry = 'https://github.com/rust-lang/crates.io-index'
-      replace-with = 'vendored-sources'
+  '' + (if useRealVendorConfig then ''
+      sed "s|directory = \".*\"|directory = \"$(pwd)/$cargoDepsCopy\"|g" \
+        "$(pwd)/$cargoDepsCopy/.cargo/config" > .cargo/config
+    '' else ''
+      cat >.cargo/config <<-EOF
+        [source.crates-io]
+        registry = 'https://github.com/rust-lang/crates.io-index'
+        replace-with = 'vendored-sources'
 
-      [source.vendored-sources]
-      directory = '$(pwd)/$cargoDepsCopy'
-    EOF
+        [source.vendored-sources]
+        directory = '$(pwd)/$cargoDepsCopy'
+      EOF
+    '') + ''
 
     unset cargoDepsCopy
 
diff --git a/pkgs/build-support/rust/fetchcargo.nix b/pkgs/build-support/rust/fetchcargo.nix
index 2670ed528640..2d8a36a30ace 100644
--- a/pkgs/build-support/rust/fetchcargo.nix
+++ b/pkgs/build-support/rust/fetchcargo.nix
@@ -1,5 +1,5 @@
 { stdenv, cacert, git, rust, cargo-vendor }:
-{ name ? "cargo-deps", src, srcs, patches, sourceRoot, sha256, cargoUpdateHook ? "" }:
+{ name ? "cargo-deps", src, srcs, patches, sourceRoot, sha256, cargoUpdateHook ? "", writeVendorConfig ? false }:
 stdenv.mkDerivation {
   name = "${name}-vendor";
   nativeBuildInputs = [ cacert cargo-vendor git rust.cargo ];
@@ -23,9 +23,11 @@ stdenv.mkDerivation {
 
     ${cargoUpdateHook}
 
-    cargo vendor
-
-    cp -ar vendor $out
+    mkdir -p $out
+    cargo vendor $out > config
+  '' + stdenv.lib.optionalString writeVendorConfig ''
+    mkdir $out/.cargo
+    sed "s|directory = \".*\"|directory = \"./vendor\"|g" config > $out/.cargo/config
   '';
 
   outputHashAlgo = "sha256";