Merge pull request #194425 from SuperSandro2000/remove-double-fixed-output

Add support for pname+version to fetchzip/fetchurl
This commit is contained in:
Anderson Torres 2022-10-06 22:24:11 -03:00 committed by GitHub
commit 10c7f50248
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 54 additions and 37 deletions

View file

@ -57,6 +57,10 @@ in
# first element of `urls').
name ? ""
# for versioned downloads optionally take pname + version.
, pname ? ""
, version ? ""
, # SRI hash.
hash ? ""
@ -130,12 +134,16 @@ let
else throw "fetchurl requires a hash for fixed-output derivation: ${lib.concatStringsSep ", " urls_}";
in
stdenvNoCC.mkDerivation {
name =
if showURLs then "urls"
else if name != "" then name
else baseNameOf (toString (builtins.head urls_));
stdenvNoCC.mkDerivation ((
if (pname != "" && version != "") then
{ inherit pname version; }
else
{ name =
if showURLs then "urls"
else if name != "" then name
else baseNameOf (toString (builtins.head urls_));
}
) // {
builder = ./builder.sh;
nativeBuildInputs = [ curl ] ++ nativeBuildInputs;
@ -177,4 +185,4 @@ stdenvNoCC.mkDerivation {
inherit meta;
passthru = { inherit url; } // passthru;
}
})

View file

@ -14,6 +14,8 @@
, extraPostFetch ? ""
, postFetch ? ""
, name ? "source"
, pname ? ""
, version ? ""
, nativeBuildInputs ? [ ]
, # Allows to set the extension for the intermediate downloaded
# file. This can be used as a hint for the unpackCmdHooks to select
@ -23,14 +25,23 @@
lib.warnIf (extraPostFetch != "") "use 'postFetch' instead of 'extraPostFetch' with 'fetchzip' and 'fetchFromGitHub'."
(fetchurl (let
(let
tmpFilename =
if extension != null
then "download.${extension}"
else baseNameOf (if url != "" then url else builtins.head urls);
in {
inherit name;
in
fetchurl ((
if (pname != "" && version != "") then
{
name = "${name}-${version}";
inherit pname version;
}
else
{ inherit name; }
) // {
recursiveHash = true;
downloadToTemp = true;

View file

@ -1,21 +1,19 @@
{ lib, stdenv, fetchzip }:
{ lib, fetchzip }:
stdenv.mkDerivation {
fetchzip rec {
pname = "cooper-hewitt";
version = "unstable-2014-06-09";
src = fetchzip {
url = "https://www.cooperhewitt.org/wp-content/uploads/fonts/CooperHewitt-OTF-public.zip";
hash = "sha256-bTlEXQeYNNspvnNdvQhJn6CNBrcSKYWuNWF/N6+3Vb0=";
};
url = "https://web.archive.org/web/20221004145117/https://www.cooperhewitt.org/wp-content/uploads/fonts/CooperHewitt-OTF-public.zip";
dontConfigure = true;
dontBuild = true;
installPhase = ''
install -D -m 644 -t "$out/share/fonts/opentype" *.otf
postFetch = ''
mkdir -p $out/share/fonts/opentype
mv $out/*.otf $out/share/fonts/opentype
find $out -maxdepth 1 ! -type d -exec rm {} +
'';
sha256 = "01iwqmjvqkc6fmc2r0486vk06s6f51n9wxzl1pf9z48n0igj4gqd";
meta = with lib; {
homepage = "https://www.cooperhewitt.org/open-source-at-cooper-hewitt/cooper-hewitt-the-typeface-by-chester-jenkins/";
description = "A contemporary sans serif, with characters composed of modified-geometric curves and arches";

View file

@ -1,16 +1,18 @@
{ lib, fetchzip }:
fetchzip rec {
name = "freefont-ttf-20120503";
pname = "freefont-ttf";
version = "20120503";
url = "mirror://gnu/freefont/${name}.zip";
url = "mirror://gnu/freefont/freefont-ttf-${version}.zip";
postFetch = ''
mkdir -p $out/share/fonts
unzip -j $downloadedFile \*.ttf -d $out/share/fonts/truetype
mkdir -p $out/share/fonts/truetype
mv $out/*.ttf $out/share/fonts/truetype
find $out -maxdepth 1 ! -type d -exec rm {} +
'';
sha256 = "0h0x2hhr7kvjiycf7fv800xxwa6hcpiz54bqx06wsqc7z61iklvd";
sha256 = "sha256-bdMZg/mHYc0N6HiR8uNl0CjeOwBou+OYj3LPkyEUHUA=";
meta = {
description = "GNU Free UCS Outline Fonts";

View file

@ -1,20 +1,18 @@
{ lib, stdenv, fetchzip }:
{ lib, fetchzip }:
stdenv.mkDerivation rec {
fetchzip rec {
pname = "ubuntu-font-family";
version = "0.83";
src = fetchzip {
url = "https://assets.ubuntu.com/v1/fad7939b-${pname}-${version}.zip";
hash = "sha256-FAg1xn8Gcbwmuvqtg9SquSet4oTT9nqE+Izeq7ZMVcA=";
};
url = "https://assets.ubuntu.com/v1/fad7939b-ubuntu-font-family-${version}.zip";
installPhase = ''
install -D -m 644 -t "$out/share/fonts/truetype" *.ttf
postFetch = ''
mkdir -p $out/share/fonts/ubuntu
mv $out/*.ttf $out/share/fonts/ubuntu
find $out -maxdepth 1 ! -type d -exec rm {} +
'';
outputHashMode = "recursive";
outputHash = "sha256-EEcYtOeOd2DKyRLo1kG7lk8euaFilCFMXMJNAosxHiQ=";
sha256 = "090y665h4kf2bi623532l6wiwkwnpd0xds0jr7560xwfwys1hiqh";
meta = with lib; {
description = "Ubuntu Font Family";
@ -25,6 +23,6 @@ stdenv.mkDerivation rec {
homepage = "http://font.ubuntu.com/";
license = licenses.free;
platforms = platforms.all;
maintainers = with maintainers; [ antono ];
maintainers = [ maintainers.antono ];
};
}