fix(3p/nix): Prepend unix:// to daemon socket
Prepend the unix:// URI scheme to the daemon socket so that grpc knows we want to connect to a unix socket rather than another type of URI. As part of debugging this I made the failure message for the RPCStore include the URI, which I'm leaving in since it'll be nice to have. Change-Id: I6e70596895117b9a0d53fe2a61d8542ceb64c940 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1543 Reviewed-by: kanepyork <rikingcoding@gmail.com> Tested-by: BuildkiteCI
This commit is contained in:
		
							parent
							
								
									1094e356df
								
							
						
					
					
						commit
						2646e57aae
					
				
					 3 changed files with 28 additions and 23 deletions
				
			
		
							
								
								
									
										44
									
								
								third_party/nix/src/libstore/store-api.cc
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										44
									
								
								third_party/nix/src/libstore/store-api.cc
									
										
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -5,6 +5,7 @@
 | 
			
		|||
 | 
			
		||||
#include <absl/strings/match.h>
 | 
			
		||||
#include <absl/strings/numbers.h>
 | 
			
		||||
#include <absl/strings/str_cat.h>
 | 
			
		||||
#include <absl/strings/str_split.h>
 | 
			
		||||
#include <glog/logging.h>
 | 
			
		||||
#include <grpcpp/create_channel.h>
 | 
			
		||||
| 
						 | 
				
			
			@ -984,28 +985,29 @@ StoreType getStoreType(const std::string& uri, const std::string& stateDir) {
 | 
			
		|||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static RegisterStoreImplementation regStore(
 | 
			
		||||
    [](const std::string& uri,
 | 
			
		||||
       const Store::Params& params) -> std::shared_ptr<Store> {
 | 
			
		||||
      switch (getStoreType(uri, get(params, "state", settings.nixStateDir))) {
 | 
			
		||||
        case tDaemon: {
 | 
			
		||||
          auto daemon_socket_uri = settings.nixDaemonSocketFile;
 | 
			
		||||
          auto channel = grpc::CreateChannel(
 | 
			
		||||
              daemon_socket_uri, grpc::InsecureChannelCredentials());
 | 
			
		||||
          return std::shared_ptr<Store>(std::make_shared<nix::store::RpcStore>(
 | 
			
		||||
              params, proto::WorkerService::NewStub(channel)));
 | 
			
		||||
        }
 | 
			
		||||
        case tLocal: {
 | 
			
		||||
          Store::Params params2 = params;
 | 
			
		||||
          if (absl::StartsWith(uri, "/")) {
 | 
			
		||||
            params2["root"] = uri;
 | 
			
		||||
          }
 | 
			
		||||
          return std::shared_ptr<Store>(std::make_shared<LocalStore>(params2));
 | 
			
		||||
        }
 | 
			
		||||
        default:
 | 
			
		||||
          return nullptr;
 | 
			
		||||
static RegisterStoreImplementation regStore([](const std::string& uri,
 | 
			
		||||
                                               const Store::Params& params)
 | 
			
		||||
                                                -> std::shared_ptr<Store> {
 | 
			
		||||
  switch (getStoreType(uri, get(params, "state", settings.nixStateDir))) {
 | 
			
		||||
    case tDaemon: {
 | 
			
		||||
      auto daemon_socket_uri =
 | 
			
		||||
          absl::StrCat("unix://", settings.nixDaemonSocketFile);
 | 
			
		||||
      auto channel = grpc::CreateChannel(daemon_socket_uri,
 | 
			
		||||
                                         grpc::InsecureChannelCredentials());
 | 
			
		||||
      return std::shared_ptr<Store>(std::make_shared<nix::store::RpcStore>(
 | 
			
		||||
          daemon_socket_uri, params, proto::WorkerService::NewStub(channel)));
 | 
			
		||||
    }
 | 
			
		||||
    case tLocal: {
 | 
			
		||||
      Store::Params params2 = params;
 | 
			
		||||
      if (absl::StartsWith(uri, "/")) {
 | 
			
		||||
        params2["root"] = uri;
 | 
			
		||||
      }
 | 
			
		||||
    });
 | 
			
		||||
      return std::shared_ptr<Store>(std::make_shared<LocalStore>(params2));
 | 
			
		||||
    }
 | 
			
		||||
    default:
 | 
			
		||||
      return nullptr;
 | 
			
		||||
  }
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
std::list<ref<Store>> getDefaultSubstituters() {
 | 
			
		||||
  static auto stores([]() {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue