diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2017-02-16T14·42+0100 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2017-02-16T14·51+0100 |
commit | 302386f775eea309679654e5ea7c972fb6e7b9af (patch) | |
tree | 57af26df9b9d0b635aac092d5803e907c0c3741a /src/libutil/util.cc | |
parent | cde4b609192d11dc299ea3c27d7f92735f161db1 (diff) |
Support netrc in <nix/fetchurl.nix>
This allows <nix/fetchurl.nix> to fetch private Git/Mercurial repositories, e.g. import <nix/fetchurl.nix> { 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).
Diffstat (limited to 'src/libutil/util.cc')
-rw-r--r-- | src/libutil/util.cc | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/libutil/util.cc b/src/libutil/util.cc index 336599368009..0a5f796e4eaa 100644 --- a/src/libutil/util.cc +++ b/src/libutil/util.cc @@ -288,9 +288,9 @@ string readFile(const Path & path, bool drain) } -void writeFile(const Path & path, const string & s) +void writeFile(const Path & path, const string & s, mode_t mode) { - AutoCloseFD fd = open(path.c_str(), O_WRONLY | O_TRUNC | O_CREAT | O_CLOEXEC, 0666); + AutoCloseFD fd = open(path.c_str(), O_WRONLY | O_TRUNC | O_CREAT | O_CLOEXEC, mode); if (!fd) throw SysError(format("opening file ‘%1%’") % path); writeFull(fd.get(), s); |