Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for pname+version to fetchzip/fetchurl #194425

Merged
23 changes: 16 additions & 7 deletions pkgs/build-support/fetchurl/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ in
# first element of `urls').
name ? ""

# for versioned downloads optionally take pname + version.
# if name is set that is preferred
SuperSandro2000 marked this conversation as resolved.
Show resolved Hide resolved
, pname ? ""
, version ? ""

, # SRI hash.
hash ? ""

Expand Down Expand Up @@ -130,12 +135,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;
Expand Down Expand Up @@ -177,4 +186,4 @@ stdenvNoCC.mkDerivation {

inherit meta;
passthru = { inherit url; } // passthru;
}
})
17 changes: 14 additions & 3 deletions pkgs/build-support/fetchzip/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down
20 changes: 9 additions & 11 deletions pkgs/data/fonts/cooper-hewitt/default.nix
Original file line number Diff line number Diff line change
@@ -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=";
};

dontConfigure = true;
dontBuild = true;
url = "https://web.archive.org/web/20221004145117/https://www.cooperhewitt.org/wp-content/uploads/fonts/CooperHewitt-OTF-public.zip";

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";
Expand Down
12 changes: 7 additions & 5 deletions pkgs/data/fonts/freefont-ttf/default.nix
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
20 changes: 9 additions & 11 deletions pkgs/data/fonts/ubuntu-font-family/default.nix
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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 ];
};
}