From 2dd3117c2723ff08c6226b71d569bcea50d58ad1 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 9 Jul 2012 15:48:55 -0400 Subject: [PATCH] Inline fetchurl.sh --- corepkgs/Makefile.am | 2 +- corepkgs/fetchurl.nix | 17 ++++++++++++----- corepkgs/fetchurl.sh | 3 --- 3 files changed, 13 insertions(+), 9 deletions(-) delete mode 100644 corepkgs/fetchurl.sh diff --git a/corepkgs/Makefile.am b/corepkgs/Makefile.am index 94d373572..729d15e7b 100644 --- a/corepkgs/Makefile.am +++ b/corepkgs/Makefile.am @@ -1,6 +1,6 @@ all-local: config.nix -files = nar.nix buildenv.nix buildenv.pl unpack-channel.nix unpack-channel.sh derivation.nix fetchurl.nix fetchurl.sh +files = nar.nix buildenv.nix buildenv.pl unpack-channel.nix unpack-channel.sh derivation.nix fetchurl.nix install-exec-local: $(INSTALL) -d $(DESTDIR)$(datadir)/nix/corepkgs diff --git a/corepkgs/fetchurl.nix b/corepkgs/fetchurl.nix index 29cf6720b..8fc1c5970 100644 --- a/corepkgs/fetchurl.nix +++ b/corepkgs/fetchurl.nix @@ -5,13 +5,20 @@ with import ; assert (outputHash != "" && outputHashAlgo != "") || md5 != "" || sha1 != "" || sha256 != ""; +let + + builder = builtins.toFile "fetchurl.sh" + '' + echo "downloading $url into $out" + ${curl} --fail --location --max-redirs 20 "$url" > "$out" + ''; + +in + derivation { name = baseNameOf (toString url); builder = shell; - args = [ "-e" ./fetchurl.sh ]; - - # Compatibility with Nix <= 0.7. - id = md5; + args = [ "-e" builder ]; # New-style output content requirements. outputHashAlgo = if outputHashAlgo != "" then outputHashAlgo else @@ -19,7 +26,7 @@ derivation { outputHash = if outputHash != "" then outputHash else if sha256 != "" then sha256 else if sha1 != "" then sha1 else md5; - inherit system url curl; + inherit system url; # No need to double the amount of network traffic preferLocalBuild = true; diff --git a/corepkgs/fetchurl.sh b/corepkgs/fetchurl.sh deleted file mode 100644 index 6d35794ca..000000000 --- a/corepkgs/fetchurl.sh +++ /dev/null @@ -1,3 +0,0 @@ -echo "downloading $url into $out" - -$curl --fail --location --max-redirs 20 "$url" > "$out"