2018-01-10 00:38:19 +01:00
|
|
|
{ stdenvNoCC, curl }: # Note that `curl' may be `null', in case of the native stdenvNoCC.
|
2005-02-21 16:52:37 +01:00
|
|
|
|
2008-08-22 17:53:21 +02:00
|
|
|
let
|
|
|
|
|
|
|
|
mirrors = import ./mirrors.nix;
|
|
|
|
|
|
|
|
# Write the list of mirrors to a file that we can reuse between
|
|
|
|
# fetchurl instantiations, instead of passing the mirrors to
|
|
|
|
# fetchurl instantiations via environment variables. This makes the
|
|
|
|
# resulting store derivations (.drv files) much smaller, which in
|
|
|
|
# turn makes nix-env/nix-instantiate faster.
|
|
|
|
mirrorsFile =
|
2018-01-10 00:38:19 +01:00
|
|
|
stdenvNoCC.mkDerivation ({
|
2008-08-22 17:53:21 +02:00
|
|
|
name = "mirrors-list";
|
|
|
|
builder = ./write-mirror-list.sh;
|
2015-02-22 20:26:39 +01:00
|
|
|
preferLocalBuild = true;
|
2008-08-22 17:53:21 +02:00
|
|
|
} // mirrors);
|
|
|
|
|
|
|
|
# Names of the master sites that are mirrored (i.e., "sourceforge",
|
|
|
|
# "gnu", etc.).
|
2013-02-06 15:00:33 +01:00
|
|
|
sites = builtins.attrNames mirrors;
|
2008-08-22 17:53:21 +02:00
|
|
|
|
2018-01-10 00:38:19 +01:00
|
|
|
impureEnvVars = stdenvNoCC.lib.fetchers.proxyImpureEnvVars ++ [
|
2012-08-13 06:01:41 +02:00
|
|
|
# This variable allows the user to pass additional options to curl
|
|
|
|
"NIX_CURL_FLAGS"
|
|
|
|
|
|
|
|
# This variable allows the user to override hashedMirrors from the
|
|
|
|
# command-line.
|
|
|
|
"NIX_HASHED_MIRRORS"
|
2013-02-06 15:15:28 +01:00
|
|
|
|
|
|
|
# This variable allows overriding the timeout for connecting to
|
|
|
|
# the hashed mirrors.
|
|
|
|
"NIX_CONNECT_TIMEOUT"
|
2012-08-13 06:01:41 +02:00
|
|
|
] ++ (map (site: "NIX_MIRRORS_${site}") sites);
|
|
|
|
|
2008-08-22 17:53:21 +02:00
|
|
|
in
|
2013-02-06 15:00:33 +01:00
|
|
|
|
2007-08-23 17:22:30 +02:00
|
|
|
{ # URL to fetch.
|
|
|
|
url ? ""
|
|
|
|
|
|
|
|
, # Alternatively, a list of URLs specifying alternative download
|
|
|
|
# locations. They are tried in order.
|
|
|
|
urls ? []
|
|
|
|
|
2013-05-16 10:18:12 +02:00
|
|
|
, # Additional curl options needed for the download to succeed.
|
|
|
|
curlOpts ? ""
|
|
|
|
|
2007-08-23 17:22:30 +02:00
|
|
|
, # Name of the file. If empty, use the basename of `url' (or of the
|
|
|
|
# first element of `urls').
|
|
|
|
name ? ""
|
|
|
|
|
|
|
|
# Different ways of specifying the hash.
|
|
|
|
, outputHash ? ""
|
|
|
|
, outputHashAlgo ? ""
|
|
|
|
, md5 ? ""
|
|
|
|
, sha1 ? ""
|
|
|
|
, sha256 ? ""
|
2016-04-13 12:56:51 +02:00
|
|
|
, sha512 ? ""
|
2008-07-23 18:04:10 +02:00
|
|
|
|
2014-05-08 14:57:20 +02:00
|
|
|
, recursiveHash ? false
|
|
|
|
|
2017-05-19 21:38:01 +02:00
|
|
|
, # Shell code to build a netrc file for BASIC auth
|
|
|
|
netrcPhase ? null
|
|
|
|
|
|
|
|
, # Impure env vars (http://nixos.org/nix/manual/#sec-advanced-attributes)
|
|
|
|
# needed for netrcPhase
|
|
|
|
netrcImpureEnvVars ? []
|
|
|
|
|
2014-05-08 14:57:20 +02:00
|
|
|
, # Shell code executed after the file has been fetched
|
2014-05-09 17:25:59 +02:00
|
|
|
# successfully. This can do things like check or transform the file.
|
2014-05-08 14:57:20 +02:00
|
|
|
postFetch ? ""
|
|
|
|
|
|
|
|
, # Whether to download to a temporary path rather than $out. Useful
|
|
|
|
# in conjunction with postFetch. The location of the temporary file
|
|
|
|
# is communicated to postFetch via $downloadedFile.
|
|
|
|
downloadToTemp ? false
|
|
|
|
|
2016-01-19 11:17:49 +01:00
|
|
|
, # If true, set executable bit on downloaded file
|
|
|
|
executable ? false
|
|
|
|
|
2008-07-23 18:04:10 +02:00
|
|
|
, # If set, don't download the file, but write a list of all possible
|
|
|
|
# URLs (resulting from resolving mirror:// URLs) to $out.
|
|
|
|
showURLs ? false
|
2015-05-24 15:52:12 +02:00
|
|
|
|
|
|
|
, # Meta information, if any.
|
|
|
|
meta ? {}
|
2017-11-05 10:12:19 +01:00
|
|
|
|
|
|
|
# Passthru information, if any.
|
|
|
|
, passthru ? {}
|
2007-08-23 17:22:30 +02:00
|
|
|
}:
|
|
|
|
|
2014-02-19 13:36:39 +01:00
|
|
|
assert builtins.isList urls;
|
2016-02-19 10:13:10 +01:00
|
|
|
assert (urls == []) != (url == "");
|
2016-04-14 13:50:21 +02:00
|
|
|
assert sha512 != "" -> builtins.compareVersions "1.11" builtins.nixVersion <= 0;
|
2005-02-21 16:52:37 +01:00
|
|
|
|
* The stdenv setup script now defines a generic builder that allows
builders for typical Autoconf-style to be much shorten, e.g.,
. $stdenv/setup
genericBuild
The generic builder does lots of stuff automatically:
- Unpacks source archives specified by $src or $srcs (it knows about
gzip, bzip2, tar, zip, and unpacked source trees).
- Determines the source tree.
- Applies patches specified by $patches.
- Fixes libtool not to search for libraries in /lib etc.
- Runs `configure'.
- Runs `make'.
- Runs `make install'.
- Strips debug information from static libraries.
- Writes nested log information (in the format accepted by
`log2xml').
There are also lots of hooks and variables to customise the generic
builder. See `stdenv/generic/docs.txt'.
* Adapted the base packages (i.e., the ones used by stdenv) to use the
generic builder.
* We now use `curl' instead of `wget' to download files in `fetchurl'.
* Neither `curl' nor `wget' are part of stdenv. We shouldn't
encourage people to download stuff in builders (impure!).
* Updated some packages.
* `buildinputs' is now `buildInputs' (but the old name also works).
* `findInputs' in the setup script now prevents inputs from being
processed multiple times (which could happen, e.g., if an input was
a propagated input of several other inputs; this caused the size
variables like $PATH to blow up exponentially in the worst case).
* Patched GNU Make to write nested log information in the format
accepted by `log2xml'. Also, prior to writing the build command,
Make now writes a line `building X' to indicate what is being
built. This is unfortunately often obscured by the gigantic tool
invocations in many Makefiles. The actual build commands are marked
`unimportant' so that they don't clutter pages generated by
`log2html'.
svn path=/nixpkgs/trunk/; revision=845
2004-03-19 17:53:04 +01:00
|
|
|
|
2007-09-11 17:00:49 +02:00
|
|
|
let
|
|
|
|
|
2014-11-23 17:10:20 +01:00
|
|
|
hasHash = showURLs || (outputHash != "" && outputHashAlgo != "")
|
2017-03-13 13:31:44 +01:00
|
|
|
|| sha1 != "" || sha256 != "" || sha512 != "";
|
2007-09-11 17:00:49 +02:00
|
|
|
urls_ = if urls != [] then urls else [url];
|
2010-04-30 22:40:42 +02:00
|
|
|
|
2010-05-03 11:13:17 +02:00
|
|
|
in
|
2010-04-30 22:40:42 +02:00
|
|
|
|
2017-04-21 16:41:09 +02:00
|
|
|
if md5 != "" then throw "fetchurl does not support md5 anymore, please use sha256 or sha512"
|
2018-01-10 00:38:19 +01:00
|
|
|
else if (!hasHash) then throw "Specify hash for fetchurl fixed-output derivation: ${stdenvNoCC.lib.concatStringsSep ", " urls_}"
|
|
|
|
else stdenvNoCC.mkDerivation {
|
2010-05-03 11:13:17 +02:00
|
|
|
name =
|
|
|
|
if showURLs then "urls"
|
|
|
|
else if name != "" then name
|
2014-05-09 15:50:40 +02:00
|
|
|
else baseNameOf (toString (builtins.head urls_));
|
2013-02-06 15:00:33 +01:00
|
|
|
|
2003-11-03 11:22:00 +01:00
|
|
|
builder = ./builder.sh;
|
2013-02-06 15:00:33 +01:00
|
|
|
|
2018-01-09 21:36:14 +01:00
|
|
|
nativeBuildInputs = [ curl ];
|
2005-02-21 16:52:37 +01:00
|
|
|
|
2010-05-03 11:13:17 +02:00
|
|
|
urls = urls_;
|
2007-08-23 17:22:30 +02:00
|
|
|
|
2007-08-27 14:44:01 +02:00
|
|
|
# If set, prefer the content-addressable mirrors
|
2013-06-25 14:05:48 +02:00
|
|
|
# (http://tarballs.nixos.org) over the original URLs.
|
2007-08-27 14:44:01 +02:00
|
|
|
preferHashedMirrors = true;
|
2007-08-23 17:22:30 +02:00
|
|
|
|
2005-02-21 16:52:37 +01:00
|
|
|
# New-style output content requirements.
|
2010-05-03 11:13:17 +02:00
|
|
|
outputHashAlgo = if outputHashAlgo != "" then outputHashAlgo else
|
2017-03-13 13:31:44 +01:00
|
|
|
if sha512 != "" then "sha512" else if sha256 != "" then "sha256" else "sha1";
|
2010-05-03 11:13:17 +02:00
|
|
|
outputHash = if outputHash != "" then outputHash else
|
2017-03-13 13:31:44 +01:00
|
|
|
if sha512 != "" then sha512 else if sha256 != "" then sha256 else sha1;
|
2010-05-03 11:13:17 +02:00
|
|
|
|
2016-01-19 11:17:49 +01:00
|
|
|
outputHashMode = if (recursiveHash || executable) then "recursive" else "flat";
|
2014-05-08 14:57:20 +02:00
|
|
|
|
2017-05-19 21:38:01 +02:00
|
|
|
inherit curlOpts showURLs mirrorsFile postFetch downloadToTemp executable;
|
|
|
|
|
|
|
|
impureEnvVars = impureEnvVars ++ netrcImpureEnvVars;
|
2010-08-04 14:37:03 +02:00
|
|
|
|
|
|
|
# Doing the download on a remote machine just duplicates network
|
|
|
|
# traffic, so don't do that.
|
|
|
|
preferLocalBuild = true;
|
2015-05-24 15:52:12 +02:00
|
|
|
|
2017-05-19 21:38:01 +02:00
|
|
|
postHook = if netrcPhase == null then null else ''
|
|
|
|
${netrcPhase}
|
|
|
|
curlOpts="$curlOpts --netrc-file $PWD/netrc"
|
|
|
|
'';
|
|
|
|
|
2015-05-24 15:52:12 +02:00
|
|
|
inherit meta;
|
2017-11-05 10:12:19 +01:00
|
|
|
inherit passthru;
|
2010-05-03 11:13:17 +02:00
|
|
|
}
|