diff --git a/doc/manual/command-ref/conf-file.xml b/doc/manual/command-ref/conf-file.xml index 598b15827..4c8f3d9d3 100644 --- a/doc/manual/command-ref/conf-file.xml +++ b/doc/manual/command-ref/conf-file.xml @@ -406,16 +406,6 @@ flag, e.g. --option gc-keep-outputs false. - binary-cache-secret-key-file - - Path of the file containing the secret key to be - used for signing binary caches. This file can be generated using - nix-store - --generate-binary-cache-key. - - - - binary-caches-parallel-connections The maximum number of parallel HTTP connections diff --git a/src/libstore/binary-cache-store.cc b/src/libstore/binary-cache-store.cc index 8b72977d6..063d1cce2 100644 --- a/src/libstore/binary-cache-store.cc +++ b/src/libstore/binary-cache-store.cc @@ -15,9 +15,10 @@ namespace nix { BinaryCacheStore::BinaryCacheStore(std::shared_ptr localStore, - const Path & secretKeyFile) + const StoreParams & params) : localStore(localStore) { + auto secretKeyFile = get(params, "secret-key", ""); if (secretKeyFile != "") secretKey = std::unique_ptr(new SecretKey(readFile(secretKeyFile))); diff --git a/src/libstore/binary-cache-store.hh b/src/libstore/binary-cache-store.hh index b732abc38..f6fa0cac0 100644 --- a/src/libstore/binary-cache-store.hh +++ b/src/libstore/binary-cache-store.hh @@ -21,7 +21,8 @@ private: protected: - BinaryCacheStore(std::shared_ptr localStore, const Path & secretKeyFile); + BinaryCacheStore(std::shared_ptr localStore, + const StoreParams & params); [[noreturn]] void notImpl(); diff --git a/src/libstore/http-binary-cache-store.cc b/src/libstore/http-binary-cache-store.cc index 392945ca7..92d94aeea 100644 --- a/src/libstore/http-binary-cache-store.cc +++ b/src/libstore/http-binary-cache-store.cc @@ -16,8 +16,8 @@ private: public: HttpBinaryCacheStore(std::shared_ptr localStore, - const Path & secretKeyFile, const Path & _cacheUri) - : BinaryCacheStore(localStore, secretKeyFile) + const StoreParams & params, const Path & _cacheUri) + : BinaryCacheStore(localStore, params) , cacheUri(_cacheUri) , downloaders( std::numeric_limits::max(), @@ -92,8 +92,7 @@ static RegisterStoreImplementation regStore([]( if (std::string(uri, 0, 7) != "http://" && std::string(uri, 0, 8) != "https://") return 0; auto store = std::make_shared(std::shared_ptr(0), - settings.get("binary-cache-secret-key-file", string("")), - uri); + params, uri); store->init(); return store; }); diff --git a/src/libstore/local-binary-cache-store.cc b/src/libstore/local-binary-cache-store.cc index 2ec9a0d10..b6e72b039 100644 --- a/src/libstore/local-binary-cache-store.cc +++ b/src/libstore/local-binary-cache-store.cc @@ -12,7 +12,11 @@ private: public: LocalBinaryCacheStore(std::shared_ptr localStore, - const Path & secretKeyFile, const Path & binaryCacheDir); + const StoreParams & params, const Path & binaryCacheDir) + : BinaryCacheStore(localStore, params) + , binaryCacheDir(binaryCacheDir) + { + } void init() override; @@ -31,13 +35,6 @@ protected: }; -LocalBinaryCacheStore::LocalBinaryCacheStore(std::shared_ptr localStore, - const Path & secretKeyFile, const Path & binaryCacheDir) - : BinaryCacheStore(localStore, secretKeyFile) - , binaryCacheDir(binaryCacheDir) -{ -} - void LocalBinaryCacheStore::init() { createDirs(binaryCacheDir + "/nar"); @@ -74,23 +71,15 @@ std::shared_ptr LocalBinaryCacheStore::getFile(const std::string & } } -ref openLocalBinaryCacheStore(std::shared_ptr localStore, - const Path & secretKeyFile, const Path & binaryCacheDir) -{ - auto store = make_ref( - localStore, secretKeyFile, binaryCacheDir); - store->init(); - return store; -} - static RegisterStoreImplementation regStore([]( const std::string & uri, const StoreParams & params) -> std::shared_ptr { if (std::string(uri, 0, 7) != "file://") return 0; - return openLocalBinaryCacheStore(std::shared_ptr(0), - settings.get("binary-cache-secret-key-file", string("")), - std::string(uri, 7)); + auto store = std::make_shared( + std::shared_ptr(0), params, std::string(uri, 7)); + store->init(); + return store; }); } diff --git a/src/libstore/s3-binary-cache-store.cc b/src/libstore/s3-binary-cache-store.cc index cd88a3271..58ee0b638 100644 --- a/src/libstore/s3-binary-cache-store.cc +++ b/src/libstore/s3-binary-cache-store.cc @@ -43,8 +43,8 @@ struct S3BinaryCacheStoreImpl : public S3BinaryCacheStore Stats stats; S3BinaryCacheStoreImpl(std::shared_ptr localStore, - const Path & secretKeyFile, const std::string & bucketName) - : S3BinaryCacheStore(localStore, secretKeyFile) + const StoreParams & params, const std::string & bucketName) + : S3BinaryCacheStore(localStore, params) , bucketName(bucketName) , config(makeConfig()) , client(make_ref(*config)) @@ -245,8 +245,7 @@ static RegisterStoreImplementation regStore([]( { if (std::string(uri, 0, 5) != "s3://") return 0; auto store = std::make_shared(std::shared_ptr(0), - settings.get("binary-cache-secret-key-file", string("")), - std::string(uri, 5)); + params, std::string(uri, 5)); store->init(); return store; }); diff --git a/src/libstore/s3-binary-cache-store.hh b/src/libstore/s3-binary-cache-store.hh index 0425f6bb9..2751a9d01 100644 --- a/src/libstore/s3-binary-cache-store.hh +++ b/src/libstore/s3-binary-cache-store.hh @@ -11,8 +11,8 @@ class S3BinaryCacheStore : public BinaryCacheStore protected: S3BinaryCacheStore(std::shared_ptr localStore, - const Path & secretKeyFile) - : BinaryCacheStore(localStore, secretKeyFile) + const StoreParams & params) + : BinaryCacheStore(localStore, params) { } public: diff --git a/src/libstore/store-api.hh b/src/libstore/store-api.hh index cdde0be7b..29685c9d1 100644 --- a/src/libstore/store-api.hh +++ b/src/libstore/store-api.hh @@ -529,10 +529,6 @@ ref openStoreAt(const std::string & uri); ref openStore(); -ref openLocalBinaryCacheStore(std::shared_ptr localStore, - const Path & secretKeyFile, const Path & binaryCacheDir); - - /* Return the default substituter stores, defined by the ‘substituters’ option and various legacy options like ‘binary-caches’. */