···11+{ stdenv, curl, adc_user, adc_pass }:
22+33+let
44+ impureEnvVars = [
55+ # We borrow these environment variables from the caller to allow
66+ # easy proxy configuration. This is impure, but a fixed-output
77+ # derivation like fetchurl is allowed to do so since its result is
88+ # by definition pure.
99+ "http_proxy" "https_proxy" "ftp_proxy" "all_proxy" "no_proxy"
1010+ ];
1111+in
1212+1313+{ # URL to fetch.
1414+ url
1515+1616+ # Hash of the downloaded file
1717+, sha256
1818+1919+, # Additional curl options needed for the download to succeed.
2020+ curlOpts ? ""
2121+2222+, # Name of the file. If empty, use the basename of `url' (or of the
2323+ # first element of `urls').
2424+ name ? ""
2525+}:
2626+2727+stdenv.mkDerivation {
2828+ name = if name != "" then name else baseNameOf (toString url);
2929+ builder = ./builder.sh;
3030+3131+ buildInputs = [ curl ];
3232+3333+ meta = {
3434+ # Password-guarded files from ADC are certainly unfree, as far as we're concerned!
3535+ license = stdenv.lib.licenses.unfree;
3636+ };
3737+3838+ outputHashAlgo = "sha256";
3939+ outputHash = sha256;
4040+ outputHashMode = "flat";
4141+4242+ inherit curlOpts url adc_user adc_pass;
4343+4444+ preferLocalBuild = true;
4545+}