fetchurl: add user agent

It would be nice to be able to track Nix requests. It's not trustworthy,
but can be helpful for stats and routing in HTTP logs.

Since `fetchurl` is used so widely, we should "magically" get a UA on
`fetchzip`, `fetchFromGitHub`, and other related fetchers.

Since `fetchurl` is only used for fixed-output derivations, this should
cause no mass rebuild.

User-Agent example: curl/7.57.0 Nixpkgs/18.03
This commit is contained in:
Dan Peebles
2017-12-23 22:20:56 +00:00
committed by Yegor Timoshenko
parent 36e02645eb
commit 0cb623c3d9
2 changed files with 17 additions and 12 deletions
+3 -1
View File
@@ -95,7 +95,7 @@ assert sha512 != "" -> builtins.compareVersions "1.11" builtins.nixVersion <= 0;
let
inherit (stdenv.lib) fileContents;
hasHash = showURLs || (outputHash != "" && outputHashAlgo != "")
|| sha1 != "" || sha256 != "" || sha512 != "";
urls_ = if urls != [] then urls else [url];
@@ -132,6 +132,8 @@ else stdenv.mkDerivation {
impureEnvVars = impureEnvVars ++ netrcImpureEnvVars;
nixpkgsVersion = fileContents ../../../.version;
# Doing the download on a remote machine just duplicates network
# traffic, so don't do that.
preferLocalBuild = true;