aboutsummaryrefslogtreecommitdiff
path: root/pkgs/build-support/fetchurl
diff options
context:
space:
mode:
authorYegor Timoshenko <yegortimoshenko@riseup.net>2018-05-18 10:39:44 +0300
committerGitHub <noreply@github.com>2018-05-18 10:39:44 +0300
commit16ed09a10eff75674e93b76370bb5b8df3adb433 (patch)
treeba47a3d02d440b2ba1eeff53430bc5f7a478d533 /pkgs/build-support/fetchurl
parent0cb623c3d996638c548c8622c7df96d2cb4d1b05 (diff)
parent4c07c5635a81698d87c7a3d254ae2fe10d3e6c31 (diff)
Merge branch 'master' into fetchurl-user-agent
Diffstat (limited to 'pkgs/build-support/fetchurl')
-rw-r--r--pkgs/build-support/fetchurl/default.nix41
-rw-r--r--pkgs/build-support/fetchurl/mirrors.nix2
2 files changed, 22 insertions, 21 deletions
diff --git a/pkgs/build-support/fetchurl/default.nix b/pkgs/build-support/fetchurl/default.nix
index 9ab3494b2b0a..f74465be9b43 100644
--- a/pkgs/build-support/fetchurl/default.nix
+++ b/pkgs/build-support/fetchurl/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, curl }: # Note that `curl' may be `null', in case of the native stdenv.
+{ lib, stdenvNoCC, curl }: # Note that `curl' may be `null', in case of the native stdenvNoCC.
let
@@ -10,7 +10,7 @@ let
# resulting store derivations (.drv files) much smaller, which in
# turn makes nix-env/nix-instantiate faster.
mirrorsFile =
- stdenv.mkDerivation ({
+ stdenvNoCC.mkDerivation ({
name = "mirrors-list";
builder = ./write-mirror-list.sh;
preferLocalBuild = true;
@@ -20,7 +20,7 @@ let
# "gnu", etc.).
sites = builtins.attrNames mirrors;
- impureEnvVars = stdenv.lib.fetchers.proxyImpureEnvVars ++ [
+ impureEnvVars = lib.fetchers.proxyImpureEnvVars ++ [
# This variable allows the user to pass additional options to curl
"NIX_CURL_FLAGS"
@@ -89,22 +89,26 @@ in
, passthru ? {}
}:
-assert builtins.isList urls;
-assert (urls == []) != (url == "");
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];
-
+ urls_ =
+ if urls != [] && url == "" then
+ (if lib.isList urls then urls
+ else throw "`urls` is not a list")
+ else if urls == [] && url != "" then [url]
+ else throw "fetchurl requires either `url` or `urls` to be set";
+
+ hash_ =
+ if md5 != "" then throw "fetchurl does not support md5 anymore, please use sha256 or sha512"
+ else if (outputHash != "" && outputHashAlgo != "") then { inherit outputHashAlgo outputHash; }
+ else if sha512 != "" then { outputHashAlgo = "sha512"; outputHash = sha512; }
+ else if sha256 != "" then { outputHashAlgo = "sha256"; outputHash = sha256; }
+ else if sha1 != "" then { outputHashAlgo = "sha1"; outputHash = sha1; }
+ else throw "fetchurl requires a hash for fixed-output derivation: ${lib.concatStringsSep ", " urls_}";
in
-if md5 != "" then throw "fetchurl does not support md5 anymore, please use sha256 or sha512"
-else if (!hasHash) then throw "Specify hash for fetchurl fixed-output derivation: ${stdenv.lib.concatStringsSep ", " urls_}"
-else stdenv.mkDerivation {
+stdenvNoCC.mkDerivation {
name =
if showURLs then "urls"
else if name != "" then name
@@ -112,7 +116,7 @@ else stdenv.mkDerivation {
builder = ./builder.sh;
- buildInputs = [ curl ];
+ nativeBuildInputs = [ curl ];
urls = urls_;
@@ -121,10 +125,7 @@ else stdenv.mkDerivation {
preferHashedMirrors = true;
# New-style output content requirements.
- outputHashAlgo = if outputHashAlgo != "" then outputHashAlgo else
- if sha512 != "" then "sha512" else if sha256 != "" then "sha256" else "sha1";
- outputHash = if outputHash != "" then outputHash else
- if sha512 != "" then sha512 else if sha256 != "" then sha256 else sha1;
+ inherit (hash_) outputHashAlgo outputHash;
outputHashMode = if (recursiveHash || executable) then "recursive" else "flat";
@@ -132,7 +133,7 @@ else stdenv.mkDerivation {
impureEnvVars = impureEnvVars ++ netrcImpureEnvVars;
- nixpkgsVersion = fileContents ../../../.version;
+ nixpkgsVersion = lib.fileContents ../../../.version;
# Doing the download on a remote machine just duplicates network
# traffic, so don't do that.
diff --git a/pkgs/build-support/fetchurl/mirrors.nix b/pkgs/build-support/fetchurl/mirrors.nix
index d612db64c122..b0d3f373a462 100644
--- a/pkgs/build-support/fetchurl/mirrors.nix
+++ b/pkgs/build-support/fetchurl/mirrors.nix
@@ -129,7 +129,7 @@ rec {
samba = [
https://www.samba.org/ftp/
- http://ftp.riken.jp/net/samba
+ http://www.samba.org/ftp/
];
# BitlBee mirrors, see https://www.bitlbee.org/main.php/mirrors.html .