Skip to content

Commit

Permalink
corepkgs/fetchurl: Enable making the downloaded file executable
Browse files Browse the repository at this point in the history
  • Loading branch information
shlevy authored and edolstra committed Jan 21, 2013
1 parent 536c85e commit d6fd6d8
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions corepkgs/fetchurl.nix
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
with import <nix/config.nix>;

{system ? builtins.currentSystem, url, outputHash ? "", outputHashAlgo ? "", md5 ? "", sha1 ? "", sha256 ? ""}:
{system ? builtins.currentSystem, url, outputHash ? "", outputHashAlgo ? "", md5 ? "", sha1 ? "", sha256 ? "", executable ? false}:

assert (outputHash != "" && outputHashAlgo != "")
|| md5 != "" || sha1 != "" || sha256 != "";

let

builder = builtins.toFile "fetchurl.sh"
''
(''
echo "downloading $url into $out"
${curl} --fail --location --max-redirs 20 --insecure "$url" > "$out"
'';
'' + (if executable then "${coreutils}/chmod +x $out" else ""));

in

Expand All @@ -25,6 +25,7 @@ derivation {
if sha256 != "" then "sha256" else if sha1 != "" then "sha1" else "md5";
outputHash = if outputHash != "" then outputHash else
if sha256 != "" then sha256 else if sha1 != "" then sha1 else md5;
outputHashMode = if executable then "recursive" else "flat";

inherit system url;

Expand Down

0 comments on commit d6fd6d8

Please sign in to comment.