1{ 2 lib, 3 rustPlatform, 4 stdenv, 5 replaceVars, 6}: 7 8{ version, src, ... }: 9 10let 11 rustDep = rustPlatform.buildRustPackage { 12 pname = "rhttp-rs"; 13 inherit version src; 14 15 sourceRoot = "${src.name}/rust"; 16 17 unpackPhase = '' 18 runHook preUnpack 19 20 if [ -d $src/rhttp ]; then 21 cp -r $src/rhttp ${src.name} 22 else 23 cp -r $src ${src.name} 24 fi 25 chmod -R u+w -- "$sourceRoot" 26 27 runHook postUnpack 28 ''; 29 30 cargoHash = 31 { 32 _0_9_1 = "sha256-ZVl1nesepZnmOWeJPOgE6IDCokQm5FedbA5MBvr5S8c="; 33 _0_9_6 = "sha256-vvzb+jNN5lmRrKJ3zqvORvdduqEHRmbp85L/9Zegh/E="; 34 _0_9_8 = "sha256-cwb1wYVXOE5YABlMxUDt+OMlDpIlipqeNI7ZFAGHCqo="; 35 _0_10_0 = "sha256-2SpAj53XvZXKRpMzFXJGcx7E2TlMUD+ooHkFwg/9fe4="; 36 _0_11_0 = "sha256-sngh5k9GoCZhnIFTpnAVHZjxTcOv+Ui6pJ2cFyriL84="; 37 _0_12_0 = "sha256-W2DcBy1n73nR2oZIQcFt6A+NElQWtfEtKB1YIweQUVo="; 38 } 39 .${"_" + (lib.replaceStrings [ "." ] [ "_" ] version)} or (throw '' 40 Unsupported version of pub 'rhttp': '${version}' 41 Please add cargoHash here. If the cargoHash 42 is the same with existing versions, add an alias here. 43 ''); 44 45 env.RUSTFLAGS = "--cfg reqwest_unstable"; 46 47 passthru.libraryPath = "lib/librhttp.so"; 48 }; 49 50in 51stdenv.mkDerivation { 52 pname = "rhttp"; 53 inherit version src; 54 inherit (src) passthru; 55 56 prePatch = '' 57 if [ -d rhttp ]; then pushd rhttp; fi 58 ''; 59 60 patches = [ 61 (replaceVars ./cargokit.patch { 62 output_lib = "${rustDep}/${rustDep.passthru.libraryPath}"; 63 }) 64 ]; 65 66 postPatch = '' 67 popd || true 68 ''; 69 70 installPhase = '' 71 runHook preInstall 72 73 cp -r . $out 74 75 runHook postInstall 76 ''; 77}