summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Peebles <pumpkin@me.com>2016-08-15 10:27:39 -0400
committerDan Peebles <pumpkin@me.com>2016-08-15 10:46:55 -0400
commitcfe35e98aa7e6e87bddc0719a3e3c5b7276f7cc2 (patch)
tree444192e503b3564e39f8f5a27c85a49e4cbe948f
parentRemove kde5PackagesFun (diff)
downloadnixpkgs-gitlab.intr/fetchurl-user-agent.tar.gz
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.
-rw-r--r--pkgs/build-support/fetchurl/builder.sh1
-rw-r--r--pkgs/build-support/fetchurl/default.nix2
2 files changed, 3 insertions, 0 deletions
diff --git a/pkgs/build-support/fetchurl/builder.sh b/pkgs/build-support/fetchurl/builder.sh
index c4fd18e46caf..ecfdbb5ff1f1 100644
--- a/pkgs/build-support/fetchurl/builder.sh
+++ b/pkgs/build-support/fetchurl/builder.sh
@@ -13,6 +13,7 @@ curl="curl \
--disable-epsv \
--cookie-jar cookies \
--insecure \
+ --user-agent "$userAgent" \
$curlOpts \
$NIX_CURL_FLAGS"
diff --git a/pkgs/build-support/fetchurl/default.nix b/pkgs/build-support/fetchurl/default.nix
index a7c76737e1ad..8336eb8bcc30 100644
--- a/pkgs/build-support/fetchurl/default.nix
+++ b/pkgs/build-support/fetchurl/default.nix
@@ -124,6 +124,8 @@ if (!hasHash) then throw "Specify hash for fetchurl fixed-output derivation: ${s
inherit curlOpts showURLs mirrorsFile impureEnvVars postFetch downloadToTemp executable;
+ userAgent = "Nix/${builtins.nixVersion}; nixpkgs/${stdenv.lib.nixpkgsVersion}";
+
# Doing the download on a remote machine just duplicates network
# traffic, so don't do that.
preferLocalBuild = true;