Merge pull request #96370 from danieldk/fetchcrate-pname

fetchCrate: accept pname besides crateName
This commit is contained in:
Maximilian Bosch 2020-08-28 13:30:37 +02:00 committed by GitHub
commit a19b2b4c03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 8 deletions

View File

@ -1,10 +1,13 @@
{ lib, fetchurl, unzip }: { lib, fetchurl, unzip }:
{ crateName { crateName ? args.pname
, pname ? null
, version , version
, sha256 , sha256
, ... } @ args: , ... } @ args:
assert pname == null || pname == crateName;
lib.overrideDerivation (fetchurl ({ lib.overrideDerivation (fetchurl ({
name = "${crateName}-${version}.tar.gz"; name = "${crateName}-${version}.tar.gz";
@ -30,6 +33,6 @@ lib.overrideDerivation (fetchurl ({
fi fi
mv "$unpackDir/$fn" "$out" mv "$unpackDir/$fn" "$out"
''; '';
} // removeAttrs args [ "crateName" "version" ])) } // removeAttrs args [ "crateName" "pname" "version" ]))
# Hackety-hack: we actually need unzip hooks, too # Hackety-hack: we actually need unzip hooks, too
(x: {nativeBuildInputs = x.nativeBuildInputs++ [unzip];}) (x: {nativeBuildInputs = x.nativeBuildInputs++ [unzip];})

View File

@ -1,6 +1,6 @@
{ stdenv { stdenv
, rustPlatform , rustPlatform
, fetchFromGitHub , fetchCrate
, installShellFiles , installShellFiles
, makeWrapper , makeWrapper
, coreutils , coreutils
@ -12,11 +12,9 @@ rustPlatform.buildRustPackage rec {
pname = "broot"; pname = "broot";
version = "0.20.3"; version = "0.20.3";
src = fetchFromGitHub { src = fetchCrate {
owner = "Canop"; inherit pname version;
repo = pname; sha256 = "0vw956c5xpjsbd9b0ardvgi9jjqb230m2x5n4h9ai0yiwizc8rh6";
rev = "v${version}";
sha256 = "0hbz7cslngl77qka8sl84fjhijbqbw69dj058ghhsgaxw06nypg2";
}; };
cargoSha256 = "1zl4p3n327iq7nm7hi79zjxv2gvw9f3lwgkg1qp52kycv1af5gqp"; cargoSha256 = "1zl4p3n327iq7nm7hi79zjxv2gvw9f3lwgkg1qp52kycv1af5gqp";