From 302386f775eea309679654e5ea7c972fb6e7b9af Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 16 Feb 2017 15:42:49 +0100 Subject: Support netrc in This allows to fetch private Git/Mercurial repositories, e.g. import { url = https://edolstra@bitbucket.org/edolstra/my-private-repo/get/80a14018daed.tar.bz2; sha256 = "1mgqzn7biqkq3hf2697b0jc4wabkqhmzq2srdymjfa6sb9zb6qs7"; } where /etc/nix/netrc contains: machine bitbucket.org login edolstra password blabla... This works even when sandboxing is enabled. To do: add unpacking support (i.e. fetchzip functionality). --- src/libstore/builtins.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/libstore/builtins.cc') diff --git a/src/libstore/builtins.cc b/src/libstore/builtins.cc index a30f30906f01..c5dbd57f8bc6 100644 --- a/src/libstore/builtins.cc +++ b/src/libstore/builtins.cc @@ -6,8 +6,16 @@ namespace nix { -void builtinFetchurl(const BasicDerivation & drv) +void builtinFetchurl(const BasicDerivation & drv, const std::string & netrcData) { + /* Make the host's netrc data available. Too bad curl requires + this to be stored in a file. It would be nice if we could just + pass a pointer to the data. */ + if (netrcData != "") { + settings.netrcFile = "netrc"; + writeFile(settings.netrcFile, netrcData, 0600); + } + auto getAttr = [&](const string & name) { auto i = drv.env.find(name); if (i == drv.env.end()) throw Error(format("attribute ā€˜%sā€™ missing") % name); -- cgit 1.4.1