Advertisement
Guest User

Untitled

a guest
Sep 10th, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.17 KB | None | 0 0
  1. diff --git a/pkgs/build-support/rust/cargo-vendor/default.nix b/pkgs/build-support/rust/cargo-vendor/default.nix
  2. index faeb6e03743..5d5e2b1d88b 100644
  3. --- a/pkgs/build-support/rust/cargo-vendor/default.nix
  4. +++ b/pkgs/build-support/rust/cargo-vendor/default.nix
  5. @@ -1,10 +1,32 @@
  6. -{ callPackage, fetchFromGitHub }:
  7. +{ stdenv, callPackage, fetchFromGitHub, pkgconfig, openssl, curl, libssh2, cmake }:
  8. +
  9. +let
  10. + cargo-vendor-bootstrap = (callPackage ./cargo-vendor-bootstrap.nix {}).cargo_vendor_0_1_13.overrideAttrs (attrs: {
  11. + src = fetchFromGitHub {
  12. + owner = "alexcrichton";
  13. + repo = "cargo-vendor";
  14. + rev = "0.1.13";
  15. + sha256 = "0ljh2d65zpxp26a95b3czy5ai2z2dm87x7ndfdc1s0v1fsy69kn4";
  16. + };
  17. + });
  18. + buildRustPackage = callPackage ../. { cargo-vendor = cargo-vendor-bootstrap; };
  19. +in
  20. +buildRustPackage rec {
  21. + name = "cargo-vendor-${version}";
  22. + version = "0.1.16";
  23.  
  24. -(callPackage ./cargo-vendor.nix {}).cargo_vendor_0_1_13.overrideAttrs (attrs: {
  25. src = fetchFromGitHub {
  26. owner = "alexcrichton";
  27. repo = "cargo-vendor";
  28. - rev = "0.1.13";
  29. - sha256 = "0ljh2d65zpxp26a95b3czy5ai2z2dm87x7ndfdc1s0v1fsy69kn4";
  30. + rev = "${version}";
  31. + sha256 = "03pllm7y9k1sk8ch5rz6wlmj19k5niv32rn89fwsw0mfv0hcfs35";
  32. };
  33. -})
  34. +
  35. + cargoSha256 = "0g4p12hikmw4whdqkjamj5kbbwih0l3i67h728hjdb4q8phn6vvg";
  36. +
  37. + buildInputs = [ openssl curl libssh2 ];
  38. +
  39. + nativeBuildInputs = [ pkgconfig cmake ];
  40. +
  41. + doCheck = false;
  42. +}
  43. diff --git a/pkgs/build-support/rust/default.nix b/pkgs/build-support/rust/default.nix
  44. index 820989a7620..68654538d75 100644
  45. --- a/pkgs/build-support/rust/default.nix
  46. +++ b/pkgs/build-support/rust/default.nix
  47. @@ -30,14 +30,19 @@ let
  48. }
  49. else null;
  50.  
  51. - setupVendorDir = if cargoVendorDir == null
  52. + setupCargoConfig = if cargoVendorDir == null
  53. then ''
  54. - unpackFile "$cargoDeps"
  55. - cargoDepsCopy=$(stripHash $(basename $cargoDeps))
  56. - chmod -R +w "$cargoDepsCopy"
  57. + cp ${cargoDeps}/config .cargo/config
  58. ''
  59. else ''
  60. - cargoDepsCopy="$sourceRoot/${cargoVendorDir}"
  61. + cat >.cargo/config <<-EOF
  62. + [source.crates-io]
  63. + registry = 'https://github.com/rust-lang/crates.io-index'
  64. + replace-with = 'vendored-sources'
  65. +
  66. + [source.vendored-sources]
  67. + directory = '$(pwd)/$sourceRoot/${cargoVendorDir}'
  68. + EOF
  69. '';
  70.  
  71. in stdenv.mkDerivation (args // {
  72. @@ -58,19 +63,8 @@ in stdenv.mkDerivation (args // {
  73. postUnpack = ''
  74. eval "$cargoDepsHook"
  75.  
  76. - ${setupVendorDir}
  77. -
  78. mkdir .cargo
  79. - cat >.cargo/config <<-EOF
  80. - [source.crates-io]
  81. - registry = 'https://github.com/rust-lang/crates.io-index'
  82. - replace-with = 'vendored-sources'
  83. -
  84. - [source.vendored-sources]
  85. - directory = '$(pwd)/$cargoDepsCopy'
  86. - EOF
  87. -
  88. - unset cargoDepsCopy
  89. + ${setupCargoConfig}
  90.  
  91. export RUST_LOG=${logLevel}
  92. '' + (args.postUnpack or "");
  93. diff --git a/pkgs/build-support/rust/fetchcargo.nix b/pkgs/build-support/rust/fetchcargo.nix
  94. index 2670ed52864..91520009740 100644
  95. --- a/pkgs/build-support/rust/fetchcargo.nix
  96. +++ b/pkgs/build-support/rust/fetchcargo.nix
  97. @@ -9,23 +9,32 @@ stdenv.mkDerivation {
  98.  
  99. installPhase = ''
  100. if [[ ! -f Cargo.lock ]]; then
  101. - echo
  102. - echo "ERROR: The Cargo.lock file doesn't exist"
  103. - echo
  104. - echo "Cargo.lock is needed to make sure that cargoSha256 doesn't change"
  105. - echo "when the registry is updated."
  106. - echo
  107. -
  108. - exit 1
  109. + echo
  110. + echo "ERROR: The Cargo.lock file doesn't exist"
  111. + echo
  112. + echo "Cargo.lock is needed to make sure that cargoSha256 doesn't change"
  113. + echo "when the registry is updated."
  114. + echo
  115. +
  116. + exit 1
  117. fi
  118.  
  119. export CARGO_HOME=$(mktemp -d cargo-home.XXX)
  120.  
  121. ${cargoUpdateHook}
  122.  
  123. - cargo vendor
  124. + cargo vendor > config
  125. +
  126. + LINENUMBER=$(grep -rne "\[source.vendored-sources\]" config | cut -d ':' -f 1)
  127. + sed -i -e "$LINENUMBER,+1d;" config
  128. +
  129. + cat <<EOF >> config
  130. + [source.vendored-sources]
  131. + directory = "$out"
  132. + EOF
  133.  
  134. cp -ar vendor $out
  135. + cp config $out/config
  136. '';
  137.  
  138. outputHashAlgo = "sha256";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement