about summary refs log tree commit diff
path: root/src/libstore/download.hh
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2016-02-29T17·15+0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2016-03-02T14·46+0100
commit201b48de60751979835037a4b4f78128ba3fb7b3 (patch)
treedcc039210973ef48ed3fe4e46d54c500ae902a08 /src/libstore/download.hh
parent0402b6398d879889a621d60d049f8d81ac4ed86a (diff)
Add an HTTP binary cache store
Allowing stuff like

  NIX_REMOTE=https://cache.nixos.org nix-store -qR /nix/store/x1p1gl3a4kkz5ci0nfbayjqlqmczp1kq-geeqie-1.1

or

  NIX_REMOTE=https://cache.nixos.org nix-store --export /nix/store/x1p1gl3a4kkz5ci0nfbayjqlqmczp1kq-geeqie-1.1 | nix-store --import
Diffstat (limited to 'src/libstore/download.hh')
-rw-r--r--src/libstore/download.hh23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/libstore/download.hh b/src/libstore/download.hh
index 7aec8de73e48..5dd2d2c82dec 100644
--- a/src/libstore/download.hh
+++ b/src/libstore/download.hh
@@ -10,7 +10,8 @@ struct DownloadOptions
 {
     string expectedETag;
     bool verifyTLS{true};
-    bool forceProgress{false};
+    enum { yes, no, automatic } showProgress{yes};
+    bool head{false};
 };
 
 struct DownloadResult
@@ -21,11 +22,25 @@ struct DownloadResult
 
 class Store;
 
-DownloadResult downloadFile(string url, const DownloadOptions & options);
+struct Downloader
+{
+    virtual DownloadResult download(string url, const DownloadOptions & options) = 0;
+
+    Path downloadCached(ref<Store> store, const string & url, bool unpack);
+
+    enum Error { NotFound, Forbidden, Misc };
+};
 
-Path downloadFileCached(ref<Store> store, const string & url, bool unpack);
+ref<Downloader> makeDownloader();
 
-MakeError(DownloadError, Error)
+class DownloadError : public Error
+{
+public:
+    Downloader::Error error;
+    DownloadError(Downloader::Error error, const FormatOrString & fs)
+        : Error(fs), error(error)
+    { }
+};
 
 bool isUri(const string & s);