nixpkgs/pkgs/build-support
Alexey Shmalko 1893e2be4d
fetchzip: add extension parameter
fetchzip downloads the file from specified URL, renames it to basename
of that url, and then relies on unzip to do the unpacking.

The first consequence is that this requires URL to end with proper
extension—otherwise it will fail to unpack. This is not always the
case and input-fonts workarounds this by adding “&.zip” query
parameter (which is obviously a hack and is not guaranteed to work
with every URL).

The second consequence is that basename of the url must be a valid
filename. I’ve tried to build a custom configuration of input-fonts
and I get an error from mv that the filename is too long:

> trying https://input.djr.com/build/?fontSelection=fourStyleFamily&regular=InputMonoNarrow-Regular&italic=InputMonoNarrow-Italic&bold=InputMonoNarrow-Bold&boldItalic=InputMonoNarrow-BoldItalic&a=0&g=0&i=topserif&l=serifs_round&zero=0&asterisk=height&braces=straight&preset=default&line-height=1.2&accept=I+do&email=&.zip
>   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
>                                  Dload  Upload   Total   Spent    Left  Speed
> 100  406k  100  406k    0     0   230k      0  0:00:01  0:00:01 --:--:--  230k
> mv: failed to access '/build/?fontSelection=fourStyleFamily&regular=InputMonoNarrow-Regular&italic=InputMonoNarrow-Italic&bold=InputMonoNarrow-Bold&boldItalic=InputMonoNarrow-BoldItalic&a=0&g=0&i=topserif&l=serifs_round&zero=0&asterisk=height&braces=straight&preset=default&line-height=1.2&accept=I+do&email=&.zip': File name too long

We could use “name” parameter as the filename (that’s how it is used
in fetchurl). However, the previous attempt to do
so (fc01353703) was
reverted (24b5eb61eb) because of the
introduced regression—many fetchzip invocations use names without
extension (also the default name is just “source”).

This commit adds an optional “extension” parameter. If it is set,
fetchzip renames the downloaded file to “download.${extension}”
effectively solving both problems above without introducing a massive
regression.

This is a no-op for all existing packages.

Tested by updating my NixOS setup + the extra inputs-fonts
configuration mentioned above + tons of unstable emacs packages after
a nix-collect-garbage (3Gb downloaded) with this patch applied.
2021-08-10 19:57:08 +03:00
..
add-opengl-runpath
agda agdaPackages: Don't build broken packages on hydra 2021-07-22 17:29:09 +02:00
alternatives treewide: stdenv.lib -> lib 2021-01-24 01:49:49 +01:00
appimage appimageTools.wrapAppImage: Fix passing arguments to wrapped executable 2021-07-01 17:16:10 -07:00
bintools-wrapper Merge master into staging-next 2021-07-25 06:01:27 +00:00
build-bazel-package buildBazelPackage: set fetchConfigured default to true 2021-06-07 02:04:01 +00:00
build-dotnet-package treewide: pkgs.pkgconfig -> pkgs.pkg-config, move pkgconfig to alias.nix 2021-01-19 01:16:25 -08:00
build-fhs-userenv build-fhs-userenv: fix defaults on aarch64 2021-07-30 11:23:37 +02:00
build-fhs-userenv-bubblewrap build-fhs-user-env-bubblewrap: add compatibility for pipewire alsa emulation 2021-07-10 12:50:52 +02:00
build-setupcfg
buildenv trivial-builders: merge passAsFile with env in runCommand' 2021-03-18 19:56:40 +01:00
cc-wrapper gprbuild, xmlada: init at 21.0.0 2021-08-03 14:58:49 +02:00
coq mkCoqDerivation: fix useDune2 2021-06-10 21:52:03 +02:00
docker Merge pull request #132626 from zowoq/tarsum 2021-08-05 12:14:35 +02:00
dotnetbuildhelpers treewide: pkgs.pkgconfig -> pkgs.pkg-config, move pkgconfig to alias.nix 2021-01-19 01:16:25 -08:00
dotnetenv treewide: stdenv.lib -> lib 2021-01-24 01:49:49 +01:00
emacs Merge pull request #130021 from neosimsim/fix-emacs-override-examples 2021-08-04 03:08:33 -05:00
expand-response-params responsie file logic 2021-02-09 09:46:47 +08:00
fetchbitbucket fetchFromBitbucket: remove hack for Mercurial 2021-02-08 17:54:12 +00:00
fetchbower
fetchbzr treewide: editorconfig fixes 2021-01-20 09:11:11 +10:00
fetchcvs fetchcvs: fix ssh wrapper failing due to missing /usr/bin/env 2021-02-08 19:18:17 +01:00
fetchdarcs
fetchdocker fix: fetchdocker call signature 2021-05-08 23:57:32 +02:00
fetchfirefoxaddon Merge pull request #106481 from tadfisher/patch-3 2021-01-30 22:31:24 +09:00
fetchfossil fetchfossil: Depend on cacert 2020-10-24 16:43:05 +05:30
fetchgit nix-prefetch-git: don't fetch everything when given a hash 2021-07-12 20:50:52 +02:00
fetchgitea fetchFromGitea: init 2021-05-27 09:35:56 +02:00
fetchgithub fetchFromGitHub: also use git if deepClone or leaveDotGit is used 2020-12-21 13:20:04 +01:00
fetchgitiles fetchFromGitiles: init 2019-12-02 22:44:33 +00:00
fetchgitlab fetchgitlab: add deepClone, fetchSubmodules, leaveDotGit arguments 2021-07-22 13:09:14 +02:00
fetchgitlocal
fetchgx
fetchhg treewide: stdenvNoCC.lib -> lib 2021-01-27 13:01:51 +07:00
fetchipfs
fetchmavenartifact treewide: stdenv.lib -> lib 2021-01-24 01:49:49 +01:00
fetchmtn treewide: stdenvNoCC.lib -> lib 2021-01-27 13:01:51 +07:00
fetchnuget treewide: unzip buildInputs to nativeBuildInputs (#112302) 2021-02-20 16:01:53 -05:00
fetchpatch fetchpatch: Allow using base64-encoded hash 2020-03-02 23:57:40 +01:00
fetchrepoorcz
fetchrepoproject treewide: stdenvNoCC.lib -> lib 2021-01-27 13:01:51 +07:00
fetchs3 treewide: remove stdenv where not needed 2021-03-04 19:54:50 +07:00
fetchsavannah
fetchsourcehut fetchFromSourcehut: init 2021-03-08 15:51:24 +01:00
fetchsvn treewide: stdenvNoCC.lib -> lib 2021-01-27 13:01:51 +07:00
fetchsvnrevision pkgs/*: add final newline to .nix files 2020-11-09 11:39:28 +00:00
fetchsvnssh
fetchurl fetchurl: replace dead sourceforge mirrors (#130834) 2021-07-20 22:32:28 +02:00
fetchzip fetchzip: add extension parameter 2021-08-10 19:57:08 +03:00
go garble: fix aarch64 build 2021-02-20 21:13:46 +10:00
icon-conv-tools application/development: /s/name/pname&version/ 2021-06-30 09:55:22 +02:00
install-shell-files Recover the complicated situation after my bad merge 2020-10-26 09:01:04 +01:00
kernel make-initrd: fix #132059 2021-08-08 07:53:59 +02:00
libredirect application/development: /s/name/pname&version/ 2021-06-30 09:55:22 +02:00
make-desktopitem build-support/make-desktopitem: add some missing fields 2021-06-04 17:48:46 +02:00
make-startupitem
make-symlinks
mkshell mkShell: introduce packages argument (#122180) 2021-05-13 19:17:29 +02:00
mono-dll-fixer
nix-gitignore nix-gitignore: fix evaluation when .gitignore contains \# or \! (#130643) 2021-07-22 12:18:10 -04:00
nuke-references nukeReferences: fix code signatures on aarch64-darwin 2021-05-17 00:27:03 +09:00
ocaml build-support.ocaml.dune: handle minimalOCamlVersion typo 2021-06-11 11:08:12 +02:00
oci-tools ociTools: init 2019-09-04 22:46:42 +00:00
pkg-config-wrapper pkg-config-wrapper: mangle PKG_CONFIG_PATH{,_FOR_BUILD} correctly 2021-05-18 00:13:27 +02:00
prefer-remote-fetch
references-by-popularity
release releaseTools: fix nixBuild function 2021-03-29 21:24:00 +02:00
remove-references-to removeReferencesTo: fix code signatures on aarch64-darwin 2021-05-17 00:27:03 +09:00
replace-secret replace-secret: Init 2021-05-19 09:32:00 +02:00
rust rustPlatform.importCargoLock: add an assert for old Cargo.locks 2021-07-18 18:19:50 +03:00
setup-hooks stdenv: add link to clarify 2021-07-19 14:50:01 +09:00
singularity-tools treewide: stdenv.lib -> lib 2021-01-24 01:49:49 +01:00
skaware skawarePackages.buildPackage: add me as maintainer 2021-06-16 07:59:51 +00:00
snap
src-only srcOnly: rename buildInputs to nativeBuildInputs 2020-04-27 14:31:40 +02:00
substitute
substitute-files treewide: stdenv.lib -> lib 2021-01-24 01:49:49 +01:00
templaterpm treewide: makeWrapper buildInputs to nativeBuildInputs 2021-02-19 20:09:16 +07:00
trivial-builders trivial-builders: refactor writeTextFile to be overridable 2021-06-18 01:39:59 +02:00
upstream-updater treewide: remove redundant rec 2019-08-28 11:07:32 +00:00
vm vmTools: update current maintained debian versions 2021-05-27 07:33:11 +02:00
wrapper-common Merge pull request #123989 from Mic92/static-pie 2021-05-25 06:32:25 +01:00
writers tests.writers: also expose path via passthru 2021-07-13 15:22:34 +02:00
build-maven.nix
build-pecl.nix php: Run nixpkgs-fmt on all php related files 2021-06-26 20:07:56 +02:00
closure-info.nix
dhall-to-nix.nix treewide: remove redundant quotes 2019-09-08 23:38:31 +00:00
plugins.nix treewide: remove stdenv where not needed 2021-01-25 18:31:47 +01:00
replace-dependency.nix
setup-systemd-units.nix setupSystemdUnits: use /nix/var/nix/profiles/default/lib/systemd/system as fallback 2021-02-12 12:53:20 +01:00
source-from-head-fun.nix
trivial-builders.nix trivial-builders: refactor writeTextFile to be overridable 2021-06-18 01:39:59 +02:00