2020-10-11 20:18:26 +03:00
|
|
|
#pragma once
|
2023-04-01 06:18:41 +03:00
|
|
|
///@file
|
2020-10-11 20:18:26 +03:00
|
|
|
|
2020-10-11 19:01:53 +03:00
|
|
|
#include "remote-store.hh"
|
2023-04-17 20:40:46 +03:00
|
|
|
#include "remote-store-connection.hh"
|
2023-03-23 16:06:45 +02:00
|
|
|
#include "indirect-root-store.hh"
|
2020-10-11 20:18:26 +03:00
|
|
|
|
|
|
|
namespace nix {
|
|
|
|
|
|
|
|
struct UDSRemoteStoreConfig : virtual LocalFSStoreConfig, virtual RemoteStoreConfig
|
|
|
|
{
|
2024-07-18 06:32:27 +03:00
|
|
|
// TODO(fzakaria): Delete this constructor once moved over to the factory pattern
|
|
|
|
// outlined in https://github.com/NixOS/nix/issues/10766
|
|
|
|
using LocalFSStoreConfig::LocalFSStoreConfig;
|
|
|
|
using RemoteStoreConfig::RemoteStoreConfig;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param authority is the socket path.
|
|
|
|
*/
|
|
|
|
UDSRemoteStoreConfig(
|
|
|
|
std::string_view scheme,
|
|
|
|
std::string_view authority,
|
|
|
|
const Params & params);
|
2020-10-11 20:18:26 +03:00
|
|
|
|
|
|
|
const std::string name() override { return "Local Daemon Store"; }
|
2023-03-21 15:03:05 +02:00
|
|
|
|
2023-06-12 12:10:55 +03:00
|
|
|
std::string doc() override;
|
2024-07-18 06:32:27 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The path to the unix domain socket.
|
|
|
|
*
|
|
|
|
* The default is `settings.nixDaemonSocketFile`, but we don't write
|
|
|
|
* that below, instead putting in the constructor.
|
|
|
|
*/
|
|
|
|
Path path;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
static constexpr char const * scheme = "unix";
|
2024-07-16 06:26:39 +03:00
|
|
|
|
|
|
|
public:
|
|
|
|
static std::set<std::string> uriSchemes()
|
|
|
|
{ return {scheme}; }
|
2020-10-11 20:18:26 +03:00
|
|
|
};
|
|
|
|
|
2023-03-23 16:06:45 +02:00
|
|
|
class UDSRemoteStore : public virtual UDSRemoteStoreConfig
|
|
|
|
, public virtual IndirectRootStore
|
|
|
|
, public virtual RemoteStore
|
2020-10-11 20:18:26 +03:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2024-07-18 06:32:27 +03:00
|
|
|
/**
|
|
|
|
* @deprecated This is the old API to construct the store.
|
|
|
|
*/
|
2020-10-11 20:18:26 +03:00
|
|
|
UDSRemoteStore(const Params & params);
|
2024-07-18 06:32:27 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param authority is the socket path.
|
|
|
|
*/
|
2024-01-25 17:31:52 +02:00
|
|
|
UDSRemoteStore(
|
|
|
|
std::string_view scheme,
|
2024-07-18 06:32:27 +03:00
|
|
|
std::string_view authority,
|
2024-01-25 17:31:52 +02:00
|
|
|
const Params & params);
|
2020-10-11 20:18:26 +03:00
|
|
|
|
|
|
|
std::string getUri() override;
|
|
|
|
|
2023-09-04 16:51:23 +03:00
|
|
|
ref<SourceAccessor> getFSAccessor(bool requireValidPath = true) override
|
2023-11-01 18:09:28 +02:00
|
|
|
{ return LocalFSStore::getFSAccessor(requireValidPath); }
|
2020-10-11 20:18:26 +03:00
|
|
|
|
|
|
|
void narFromPath(const StorePath & path, Sink & sink) override
|
|
|
|
{ LocalFSStore::narFromPath(path, sink); }
|
|
|
|
|
2023-03-23 16:06:45 +02:00
|
|
|
/**
|
|
|
|
* Implementation of `IndirectRootStore::addIndirectRoot()` which
|
|
|
|
* delegates to the remote store.
|
|
|
|
*
|
|
|
|
* The idea is that the client makes the direct symlink, so it is
|
|
|
|
* owned managed by the client's user account, and the server makes
|
|
|
|
* the indirect symlink.
|
|
|
|
*/
|
|
|
|
void addIndirectRoot(const Path & path) override;
|
|
|
|
|
2020-10-11 20:18:26 +03:00
|
|
|
private:
|
|
|
|
|
2021-09-23 19:01:04 +03:00
|
|
|
struct Connection : RemoteStore::Connection
|
|
|
|
{
|
|
|
|
AutoCloseFD fd;
|
|
|
|
void closeWrite() override;
|
|
|
|
};
|
|
|
|
|
2020-10-11 20:18:26 +03:00
|
|
|
ref<RemoteStore::Connection> openConnection() override;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|