diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2017-07-04T14·34+0200 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2017-07-04T14·34+0200 |
commit | 42c5774e78a9f1422dee9c35adb9c056aa994d3b (patch) | |
tree | 6d162197e5993948b7f62446a5fd66ec00d74768 | |
parent | b7203e853e3b928e1a7fb081fce379f023e935bb (diff) |
Sort substituters by priority
Fixes #1438.
-rw-r--r-- | src/libstore/binary-cache-store.hh | 2 | ||||
-rw-r--r-- | src/libstore/store-api.cc | 4 | ||||
-rw-r--r-- | src/libstore/store-api.hh | 5 |
3 files changed, 11 insertions, 0 deletions
diff --git a/src/libstore/binary-cache-store.hh b/src/libstore/binary-cache-store.hh index bf5a56ab4dc3..f9c1c2cbe8a8 100644 --- a/src/libstore/binary-cache-store.hh +++ b/src/libstore/binary-cache-store.hh @@ -123,6 +123,8 @@ public: std::shared_ptr<std::string> getBuildLog(const Path & path) override; + int getPriority() override { return priority; } + }; } diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc index db2e023ab0bf..108e2d4ce9b0 100644 --- a/src/libstore/store-api.cc +++ b/src/libstore/store-api.cc @@ -812,6 +812,10 @@ std::list<ref<Store>> getDefaultSubstituters() for (auto uri : settings.extraSubstituters.get()) addStore(uri); + stores.sort([](ref<Store> & a, ref<Store> & b) { + return a->getPriority() < b->getPriority(); + }); + return stores; } ()); diff --git a/src/libstore/store-api.hh b/src/libstore/store-api.hh index c625a363033a..cada37653e6f 100644 --- a/src/libstore/store-api.hh +++ b/src/libstore/store-api.hh @@ -590,6 +590,11 @@ public: a notion of connection. Otherwise this is a no-op. */ virtual void connect() { }; + /* Get the priority of the store, used to order substituters. In + particular, binary caches can specify a priority field in their + "nix-cache-info" file. Lower value means higher priority. */ + virtual int getPriority() { return 0; } + protected: Stats stats; |