Unverified Commit 1f0f59d5 authored by éclairevoyant's avatar éclairevoyant
Browse files

rustPlatform.fetchCargoTarball: nixfmt

parent 7bf5ade7
Loading
Loading
Loading
Loading
+142 −115
Original line number Diff line number Diff line
{ lib, stdenv, cacert, git, cargo, python3 }:
let cargo-vendor-normalise = stdenv.mkDerivation {
{
  lib,
  stdenv,
  cacert,
  git,
  cargo,
  python3,
}:
let
  cargo-vendor-normalise = stdenv.mkDerivation {
    name = "cargo-vendor-normalise";
    src = ./cargo-vendor-normalise.py;
    nativeBuildInputs = [ python3.pkgs.wrapPython ];
@@ -17,27 +25,41 @@ let cargo-vendor-normalise = stdenv.mkDerivation {
    preferLocalBuild = true;
  };
in
{ name ? "cargo-deps"
, src ? null
, srcs ? []
, patches ? []
, sourceRoot ? ""
, cargoUpdateHook ? ""
, nativeBuildInputs ? []
, ...
{
  name ? "cargo-deps",
  src ? null,
  srcs ? [ ],
  patches ? [ ],
  sourceRoot ? "",
  cargoUpdateHook ? "",
  nativeBuildInputs ? [ ],
  ...
}@args:

let hash_ =
let
  hash_ =
    if args ? hash then
      {
        outputHashAlgo = if args.hash == "" then "sha256" else null;
        outputHash = args.hash;
      }
  else if args ? sha256 then { outputHashAlgo = "sha256"; outputHash = args.sha256; }
  else throw "fetchCargoTarball requires a hash for ${name}";
in stdenv.mkDerivation ({
    else if args ? sha256 then
      {
        outputHashAlgo = "sha256";
        outputHash = args.sha256;
      }
    else
      throw "fetchCargoTarball requires a hash for ${name}";
in
stdenv.mkDerivation (
  {
    name = "${name}-vendor.tar.gz";
  nativeBuildInputs = [ cacert git cargo-vendor-normalise cargo ] ++ nativeBuildInputs;
    nativeBuildInputs = [
      cacert
      git
      cargo-vendor-normalise
      cargo
    ] ++ nativeBuildInputs;

    buildPhase = ''
      runHook preBuild
@@ -111,6 +133,11 @@ in stdenv.mkDerivation ({
    inherit (hash_) outputHashAlgo outputHash;

    impureEnvVars = lib.fetchers.proxyImpureEnvVars ++ [ "NIX_CRATES_INDEX" ];
} // (builtins.removeAttrs args [
  "name" "sha256" "cargoUpdateHook" "nativeBuildInputs"
]))
  }
  // (builtins.removeAttrs args [
    "name"
    "sha256"
    "cargoUpdateHook"
    "nativeBuildInputs"
  ])
)