rustRegistry: switch to mkDerivation

fixes #26582

+40 -32
+6 -4
pkgs/build-support/rust/default.nix
··· 1 - { stdenv, callPackage, path, cacert, git, rust }: 1 + { stdenv, callPackage, path, cacert, git, rust, rustRegistry }: 2 + 3 + let 4 + rustRegistry' = rustRegistry; 5 + in 2 6 { name, depsSha256 7 + , rustRegistry ? rustRegistry' 3 8 , src ? null 4 9 , srcs ? null 5 10 , sourceRoot ? null ··· 8 13 , cargoUpdateHook ? "" 9 14 , cargoDepsHook ? "" 10 15 , cargoBuildFlags ? [] 11 - , registry ? null 12 16 , ... } @ args: 13 17 14 18 let 15 19 lib = stdenv.lib; 16 - rustRegistry = callPackage (path + /pkgs/top-level/rust-packages.nix) 17 - (lib.optionalAttrs (registry != null) { src = registry; }); 18 20 19 21 fetchDeps = import ./fetchcargo.nix { 20 22 inherit stdenv cacert git rust rustRegistry;
+2
pkgs/top-level/all-packages.nix
··· 5777 5777 inherit (darwin) apple_sdk; 5778 5778 }; 5779 5779 5780 + rustRegistry = callPackage ./rust-packages.nix { }; 5781 + 5780 5782 rust = rustStable; 5781 5783 rustStable = callPackage ../development/compilers/rust { 5782 5784 inherit (llvmPackages_4) llvm;
+32 -28
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 - , src ? fetchFromGitHub { 7 + { stdenv, fetchFromGitHub, git }: 8 + 9 + stdenv.mkDerivation { 10 + name = "rustRegistry-2017-06-25"; 11 + 12 + src = fetchFromGitHub { 9 13 owner = "rust-lang"; 10 14 repo = "crates.io-index"; 11 - rev = "cda0f689f844710a3d73c7ff459efa64997f73b5"; 12 - sha256 = "1b3brl9nn3qqaysd8lx9gaazd863grqx547iw7y9j6mkcc7sakvc"; 13 - } 14 - }: 15 - 16 - runCommand "rustRegistry" { inherit src; } '' 17 - # For some reason, cargo doesn't like fetchgit's git repositories, not even 18 - # if we set leaveDotGit to true, set the fetchgit branch to 'master' and clone 19 - # the repository (tested with registry rev 20 - # 965b634156cc5c6f10c7a458392bfd6f27436e7e), failing with the message: 21 - # 22 - # "Target OID for the reference doesn't exist on the repository" 23 - # 24 - # So we'll just have to create a new git repository from scratch with the 25 - # contents downloaded with fetchgit... 15 + rev = "9714616bf3b7836cb827d8d1eabef017d730fb5e"; 16 + sha256 = "02lpmjsqwa16j14y3jzgw4dpzfy001nfyi78x9b8rgp1w3qdjbkr"; 17 + }; 18 + phases = [ "unpackPhase" "installPhase" ]; 19 + installPhase = '' 20 + # For some reason, cargo doesn't like fetchgit's git repositories, not even 21 + # if we set leaveDotGit to true, set the fetchgit branch to 'master' and clone 22 + # the repository (tested with registry rev 23 + # 965b634156cc5c6f10c7a458392bfd6f27436e7e), failing with the message: 24 + # 25 + # "Target OID for the reference doesn't exist on the repository" 26 + # 27 + # So we'll just have to create a new git repository from scratch with the 28 + # contents downloaded with fetchgit... 26 29 27 - mkdir -p $out 30 + mkdir -p $out 28 31 29 - cp -r ${src}/* $out/ 32 + cp -r ./* $out/ 30 33 31 - cd $out 34 + cd $out 32 35 33 - git="${git}/bin/git" 36 + git="${git}/bin/git" 34 37 35 - $git init 36 - $git config --local user.email "example@example.com" 37 - $git config --local user.name "example" 38 - $git add . 39 - $git commit --quiet -m 'Rust registry commit' 38 + $git init 39 + $git config --local user.email "example@example.com" 40 + $git config --local user.name "example" 41 + $git add . 42 + $git commit --quiet -m 'Rust registry commit' 40 43 41 - touch $out/touch . "$out/.cargo-index-lock" 42 - '' 44 + touch $out/touch . "$out/.cargo-index-lock" 45 + ''; 46 + }