mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-25 23:36:16 +02:00
Merge pull request #6236 from obsidiansystems/store-dir-config
Factor out `StoreDirConfig`
This commit is contained in:
commit
fcf09813c6
32 changed files with 323 additions and 276 deletions
|
@ -9,6 +9,7 @@
|
||||||
#undef do_close
|
#undef do_close
|
||||||
|
|
||||||
#include "derivations.hh"
|
#include "derivations.hh"
|
||||||
|
#include "realisation.hh"
|
||||||
#include "globals.hh"
|
#include "globals.hh"
|
||||||
#include "store-api.hh"
|
#include "store-api.hh"
|
||||||
#include "crypto.hh"
|
#include "crypto.hh"
|
||||||
|
|
|
@ -80,7 +80,7 @@ SingleDerivedPath SingleBuiltPath::discardOutputPath() const
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
nlohmann::json BuiltPath::Built::toJSON(const Store & store) const
|
nlohmann::json BuiltPath::Built::toJSON(const StoreDirConfig & store) const
|
||||||
{
|
{
|
||||||
nlohmann::json res;
|
nlohmann::json res;
|
||||||
res["drvPath"] = drvPath->toJSON(store);
|
res["drvPath"] = drvPath->toJSON(store);
|
||||||
|
@ -90,7 +90,7 @@ nlohmann::json BuiltPath::Built::toJSON(const Store & store) const
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
nlohmann::json SingleBuiltPath::Built::toJSON(const Store & store) const
|
nlohmann::json SingleBuiltPath::Built::toJSON(const StoreDirConfig & store) const
|
||||||
{
|
{
|
||||||
nlohmann::json res;
|
nlohmann::json res;
|
||||||
res["drvPath"] = drvPath->toJSON(store);
|
res["drvPath"] = drvPath->toJSON(store);
|
||||||
|
@ -100,14 +100,14 @@ nlohmann::json SingleBuiltPath::Built::toJSON(const Store & store) const
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
nlohmann::json SingleBuiltPath::toJSON(const Store & store) const
|
nlohmann::json SingleBuiltPath::toJSON(const StoreDirConfig & store) const
|
||||||
{
|
{
|
||||||
return std::visit([&](const auto & buildable) {
|
return std::visit([&](const auto & buildable) {
|
||||||
return buildable.toJSON(store);
|
return buildable.toJSON(store);
|
||||||
}, raw());
|
}, raw());
|
||||||
}
|
}
|
||||||
|
|
||||||
nlohmann::json BuiltPath::toJSON(const Store & store) const
|
nlohmann::json BuiltPath::toJSON(const StoreDirConfig & store) const
|
||||||
{
|
{
|
||||||
return std::visit([&](const auto & buildable) {
|
return std::visit([&](const auto & buildable) {
|
||||||
return buildable.toJSON(store);
|
return buildable.toJSON(store);
|
||||||
|
|
|
@ -14,9 +14,9 @@ struct SingleBuiltPathBuilt {
|
||||||
|
|
||||||
SingleDerivedPathBuilt discardOutputPath() const;
|
SingleDerivedPathBuilt discardOutputPath() const;
|
||||||
|
|
||||||
std::string to_string(const Store & store) const;
|
std::string to_string(const StoreDirConfig & store) const;
|
||||||
static SingleBuiltPathBuilt parse(const Store & store, std::string_view, std::string_view);
|
static SingleBuiltPathBuilt parse(const StoreDirConfig & store, std::string_view, std::string_view);
|
||||||
nlohmann::json toJSON(const Store & store) const;
|
nlohmann::json toJSON(const StoreDirConfig & store) const;
|
||||||
|
|
||||||
DECLARE_CMP(SingleBuiltPathBuilt);
|
DECLARE_CMP(SingleBuiltPathBuilt);
|
||||||
};
|
};
|
||||||
|
@ -41,8 +41,8 @@ struct SingleBuiltPath : _SingleBuiltPathRaw {
|
||||||
|
|
||||||
SingleDerivedPath discardOutputPath() const;
|
SingleDerivedPath discardOutputPath() const;
|
||||||
|
|
||||||
static SingleBuiltPath parse(const Store & store, std::string_view);
|
static SingleBuiltPath parse(const StoreDirConfig & store, std::string_view);
|
||||||
nlohmann::json toJSON(const Store & store) const;
|
nlohmann::json toJSON(const StoreDirConfig & store) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline ref<SingleBuiltPath> staticDrv(StorePath drvPath)
|
static inline ref<SingleBuiltPath> staticDrv(StorePath drvPath)
|
||||||
|
@ -59,9 +59,9 @@ struct BuiltPathBuilt {
|
||||||
ref<SingleBuiltPath> drvPath;
|
ref<SingleBuiltPath> drvPath;
|
||||||
std::map<std::string, StorePath> outputs;
|
std::map<std::string, StorePath> outputs;
|
||||||
|
|
||||||
std::string to_string(const Store & store) const;
|
std::string to_string(const StoreDirConfig & store) const;
|
||||||
static BuiltPathBuilt parse(const Store & store, std::string_view, std::string_view);
|
static BuiltPathBuilt parse(const StoreDirConfig & store, std::string_view, std::string_view);
|
||||||
nlohmann::json toJSON(const Store & store) const;
|
nlohmann::json toJSON(const StoreDirConfig & store) const;
|
||||||
|
|
||||||
DECLARE_CMP(BuiltPathBuilt);
|
DECLARE_CMP(BuiltPathBuilt);
|
||||||
};
|
};
|
||||||
|
@ -89,7 +89,7 @@ struct BuiltPath : _BuiltPathRaw {
|
||||||
StorePathSet outPaths() const;
|
StorePathSet outPaths() const;
|
||||||
RealisedPath::Set toRealisedPaths(Store & store) const;
|
RealisedPath::Set toRealisedPaths(Store & store) const;
|
||||||
|
|
||||||
nlohmann::json toJSON(const Store & store) const;
|
nlohmann::json toJSON(const StoreDirConfig & store) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::vector<BuiltPath> BuiltPaths;
|
typedef std::vector<BuiltPath> BuiltPaths;
|
||||||
|
|
|
@ -22,7 +22,7 @@ struct AttrDb
|
||||||
{
|
{
|
||||||
std::atomic_bool failed{false};
|
std::atomic_bool failed{false};
|
||||||
|
|
||||||
const Store & cfg;
|
const StoreDirConfig & cfg;
|
||||||
|
|
||||||
struct State
|
struct State
|
||||||
{
|
{
|
||||||
|
@ -39,7 +39,7 @@ struct AttrDb
|
||||||
SymbolTable & symbols;
|
SymbolTable & symbols;
|
||||||
|
|
||||||
AttrDb(
|
AttrDb(
|
||||||
const Store & cfg,
|
const StoreDirConfig & cfg,
|
||||||
const Hash & fingerprint,
|
const Hash & fingerprint,
|
||||||
SymbolTable & symbols)
|
SymbolTable & symbols)
|
||||||
: cfg(cfg)
|
: cfg(cfg)
|
||||||
|
@ -323,7 +323,7 @@ struct AttrDb
|
||||||
};
|
};
|
||||||
|
|
||||||
static std::shared_ptr<AttrDb> makeAttrDb(
|
static std::shared_ptr<AttrDb> makeAttrDb(
|
||||||
const Store & cfg,
|
const StoreDirConfig & cfg,
|
||||||
const Hash & fingerprint,
|
const Hash & fingerprint,
|
||||||
SymbolTable & symbols)
|
SymbolTable & symbols)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "primops.hh"
|
#include "primops.hh"
|
||||||
#include "store-api.hh"
|
#include "store-api.hh"
|
||||||
|
#include "realisation.hh"
|
||||||
#include "make-content-addressed.hh"
|
#include "make-content-addressed.hh"
|
||||||
#include "url.hh"
|
#include "url.hh"
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,6 @@ class Symbol;
|
||||||
class PosIdx;
|
class PosIdx;
|
||||||
struct Pos;
|
struct Pos;
|
||||||
class StorePath;
|
class StorePath;
|
||||||
class Store;
|
|
||||||
class EvalState;
|
class EvalState;
|
||||||
class XMLWriter;
|
class XMLWriter;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "buildenv.hh"
|
#include "buildenv.hh"
|
||||||
|
#include "derivations.hh"
|
||||||
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
///@file
|
///@file
|
||||||
|
|
||||||
#include "derivations.hh"
|
|
||||||
#include "store-api.hh"
|
#include "store-api.hh"
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
|
@ -16,11 +16,11 @@ namespace nix {
|
||||||
/* protocol-agnostic templates */
|
/* protocol-agnostic templates */
|
||||||
|
|
||||||
#define COMMON_USE_LENGTH_PREFIX_SERIALISER(TEMPLATE, T) \
|
#define COMMON_USE_LENGTH_PREFIX_SERIALISER(TEMPLATE, T) \
|
||||||
TEMPLATE T CommonProto::Serialise< T >::read(const Store & store, CommonProto::ReadConn conn) \
|
TEMPLATE T CommonProto::Serialise< T >::read(const StoreDirConfig & store, CommonProto::ReadConn conn) \
|
||||||
{ \
|
{ \
|
||||||
return LengthPrefixedProtoHelper<CommonProto, T >::read(store, conn); \
|
return LengthPrefixedProtoHelper<CommonProto, T >::read(store, conn); \
|
||||||
} \
|
} \
|
||||||
TEMPLATE void CommonProto::Serialise< T >::write(const Store & store, CommonProto::WriteConn conn, const T & t) \
|
TEMPLATE void CommonProto::Serialise< T >::write(const StoreDirConfig & store, CommonProto::WriteConn conn, const T & t) \
|
||||||
{ \
|
{ \
|
||||||
LengthPrefixedProtoHelper<CommonProto, T >::write(store, conn, t); \
|
LengthPrefixedProtoHelper<CommonProto, T >::write(store, conn, t); \
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,40 +13,40 @@ namespace nix {
|
||||||
|
|
||||||
/* protocol-agnostic definitions */
|
/* protocol-agnostic definitions */
|
||||||
|
|
||||||
std::string CommonProto::Serialise<std::string>::read(const Store & store, CommonProto::ReadConn conn)
|
std::string CommonProto::Serialise<std::string>::read(const StoreDirConfig & store, CommonProto::ReadConn conn)
|
||||||
{
|
{
|
||||||
return readString(conn.from);
|
return readString(conn.from);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommonProto::Serialise<std::string>::write(const Store & store, CommonProto::WriteConn conn, const std::string & str)
|
void CommonProto::Serialise<std::string>::write(const StoreDirConfig & store, CommonProto::WriteConn conn, const std::string & str)
|
||||||
{
|
{
|
||||||
conn.to << str;
|
conn.to << str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
StorePath CommonProto::Serialise<StorePath>::read(const Store & store, CommonProto::ReadConn conn)
|
StorePath CommonProto::Serialise<StorePath>::read(const StoreDirConfig & store, CommonProto::ReadConn conn)
|
||||||
{
|
{
|
||||||
return store.parseStorePath(readString(conn.from));
|
return store.parseStorePath(readString(conn.from));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommonProto::Serialise<StorePath>::write(const Store & store, CommonProto::WriteConn conn, const StorePath & storePath)
|
void CommonProto::Serialise<StorePath>::write(const StoreDirConfig & store, CommonProto::WriteConn conn, const StorePath & storePath)
|
||||||
{
|
{
|
||||||
conn.to << store.printStorePath(storePath);
|
conn.to << store.printStorePath(storePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ContentAddress CommonProto::Serialise<ContentAddress>::read(const Store & store, CommonProto::ReadConn conn)
|
ContentAddress CommonProto::Serialise<ContentAddress>::read(const StoreDirConfig & store, CommonProto::ReadConn conn)
|
||||||
{
|
{
|
||||||
return ContentAddress::parse(readString(conn.from));
|
return ContentAddress::parse(readString(conn.from));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommonProto::Serialise<ContentAddress>::write(const Store & store, CommonProto::WriteConn conn, const ContentAddress & ca)
|
void CommonProto::Serialise<ContentAddress>::write(const StoreDirConfig & store, CommonProto::WriteConn conn, const ContentAddress & ca)
|
||||||
{
|
{
|
||||||
conn.to << renderContentAddress(ca);
|
conn.to << renderContentAddress(ca);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Realisation CommonProto::Serialise<Realisation>::read(const Store & store, CommonProto::ReadConn conn)
|
Realisation CommonProto::Serialise<Realisation>::read(const StoreDirConfig & store, CommonProto::ReadConn conn)
|
||||||
{
|
{
|
||||||
std::string rawInput = readString(conn.from);
|
std::string rawInput = readString(conn.from);
|
||||||
return Realisation::fromJSON(
|
return Realisation::fromJSON(
|
||||||
|
@ -55,41 +55,41 @@ Realisation CommonProto::Serialise<Realisation>::read(const Store & store, Commo
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommonProto::Serialise<Realisation>::write(const Store & store, CommonProto::WriteConn conn, const Realisation & realisation)
|
void CommonProto::Serialise<Realisation>::write(const StoreDirConfig & store, CommonProto::WriteConn conn, const Realisation & realisation)
|
||||||
{
|
{
|
||||||
conn.to << realisation.toJSON().dump();
|
conn.to << realisation.toJSON().dump();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DrvOutput CommonProto::Serialise<DrvOutput>::read(const Store & store, CommonProto::ReadConn conn)
|
DrvOutput CommonProto::Serialise<DrvOutput>::read(const StoreDirConfig & store, CommonProto::ReadConn conn)
|
||||||
{
|
{
|
||||||
return DrvOutput::parse(readString(conn.from));
|
return DrvOutput::parse(readString(conn.from));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommonProto::Serialise<DrvOutput>::write(const Store & store, CommonProto::WriteConn conn, const DrvOutput & drvOutput)
|
void CommonProto::Serialise<DrvOutput>::write(const StoreDirConfig & store, CommonProto::WriteConn conn, const DrvOutput & drvOutput)
|
||||||
{
|
{
|
||||||
conn.to << drvOutput.to_string();
|
conn.to << drvOutput.to_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::optional<StorePath> CommonProto::Serialise<std::optional<StorePath>>::read(const Store & store, CommonProto::ReadConn conn)
|
std::optional<StorePath> CommonProto::Serialise<std::optional<StorePath>>::read(const StoreDirConfig & store, CommonProto::ReadConn conn)
|
||||||
{
|
{
|
||||||
auto s = readString(conn.from);
|
auto s = readString(conn.from);
|
||||||
return s == "" ? std::optional<StorePath> {} : store.parseStorePath(s);
|
return s == "" ? std::optional<StorePath> {} : store.parseStorePath(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommonProto::Serialise<std::optional<StorePath>>::write(const Store & store, CommonProto::WriteConn conn, const std::optional<StorePath> & storePathOpt)
|
void CommonProto::Serialise<std::optional<StorePath>>::write(const StoreDirConfig & store, CommonProto::WriteConn conn, const std::optional<StorePath> & storePathOpt)
|
||||||
{
|
{
|
||||||
conn.to << (storePathOpt ? store.printStorePath(*storePathOpt) : "");
|
conn.to << (storePathOpt ? store.printStorePath(*storePathOpt) : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::optional<ContentAddress> CommonProto::Serialise<std::optional<ContentAddress>>::read(const Store & store, CommonProto::ReadConn conn)
|
std::optional<ContentAddress> CommonProto::Serialise<std::optional<ContentAddress>>::read(const StoreDirConfig & store, CommonProto::ReadConn conn)
|
||||||
{
|
{
|
||||||
return ContentAddress::parseOpt(readString(conn.from));
|
return ContentAddress::parseOpt(readString(conn.from));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommonProto::Serialise<std::optional<ContentAddress>>::write(const Store & store, CommonProto::WriteConn conn, const std::optional<ContentAddress> & caOpt)
|
void CommonProto::Serialise<std::optional<ContentAddress>>::write(const StoreDirConfig & store, CommonProto::WriteConn conn, const std::optional<ContentAddress> & caOpt)
|
||||||
{
|
{
|
||||||
conn.to << (caOpt ? renderContentAddress(*caOpt) : "");
|
conn.to << (caOpt ? renderContentAddress(*caOpt) : "");
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
class Store;
|
struct StoreDirConfig;
|
||||||
struct Source;
|
struct Source;
|
||||||
|
|
||||||
// items being serialized
|
// items being serialized
|
||||||
|
@ -48,7 +48,7 @@ struct CommonProto
|
||||||
* infer the type instead of having to write it down explicitly.
|
* infer the type instead of having to write it down explicitly.
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static void write(const Store & store, WriteConn conn, const T & t)
|
static void write(const StoreDirConfig & store, WriteConn conn, const T & t)
|
||||||
{
|
{
|
||||||
CommonProto::Serialise<T>::write(store, conn, t);
|
CommonProto::Serialise<T>::write(store, conn, t);
|
||||||
}
|
}
|
||||||
|
@ -57,8 +57,8 @@ struct CommonProto
|
||||||
#define DECLARE_COMMON_SERIALISER(T) \
|
#define DECLARE_COMMON_SERIALISER(T) \
|
||||||
struct CommonProto::Serialise< T > \
|
struct CommonProto::Serialise< T > \
|
||||||
{ \
|
{ \
|
||||||
static T read(const Store & store, CommonProto::ReadConn conn); \
|
static T read(const StoreDirConfig & store, CommonProto::ReadConn conn); \
|
||||||
static void write(const Store & store, CommonProto::WriteConn conn, const T & str); \
|
static void write(const StoreDirConfig & store, CommonProto::WriteConn conn, const T & str); \
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
std::optional<StorePath> DerivationOutput::path(const Store & store, std::string_view drvName, OutputNameView outputName) const
|
std::optional<StorePath> DerivationOutput::path(const StoreDirConfig & store, std::string_view drvName, OutputNameView outputName) const
|
||||||
{
|
{
|
||||||
return std::visit(overloaded {
|
return std::visit(overloaded {
|
||||||
[](const DerivationOutput::InputAddressed & doi) -> std::optional<StorePath> {
|
[](const DerivationOutput::InputAddressed & doi) -> std::optional<StorePath> {
|
||||||
|
@ -35,7 +35,7 @@ std::optional<StorePath> DerivationOutput::path(const Store & store, std::string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
StorePath DerivationOutput::CAFixed::path(const Store & store, std::string_view drvName, OutputNameView outputName) const
|
StorePath DerivationOutput::CAFixed::path(const StoreDirConfig & store, std::string_view drvName, OutputNameView outputName) const
|
||||||
{
|
{
|
||||||
return store.makeFixedOutputPathFromCA(
|
return store.makeFixedOutputPathFromCA(
|
||||||
outputPathName(drvName, outputName),
|
outputPathName(drvName, outputName),
|
||||||
|
@ -214,7 +214,7 @@ static StringSet parseStrings(std::istream & str, bool arePaths)
|
||||||
|
|
||||||
|
|
||||||
static DerivationOutput parseDerivationOutput(
|
static DerivationOutput parseDerivationOutput(
|
||||||
const Store & store,
|
const StoreDirConfig & store,
|
||||||
std::string_view pathS, std::string_view hashAlgo, std::string_view hashS,
|
std::string_view pathS, std::string_view hashAlgo, std::string_view hashS,
|
||||||
const ExperimentalFeatureSettings & xpSettings)
|
const ExperimentalFeatureSettings & xpSettings)
|
||||||
{
|
{
|
||||||
|
@ -261,7 +261,7 @@ static DerivationOutput parseDerivationOutput(
|
||||||
}
|
}
|
||||||
|
|
||||||
static DerivationOutput parseDerivationOutput(
|
static DerivationOutput parseDerivationOutput(
|
||||||
const Store & store, std::istringstream & str,
|
const StoreDirConfig & store, std::istringstream & str,
|
||||||
const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings)
|
const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings)
|
||||||
{
|
{
|
||||||
expect(str, ","); const auto pathS = parseString(str);
|
expect(str, ","); const auto pathS = parseString(str);
|
||||||
|
@ -290,7 +290,7 @@ enum struct DerivationATermVersion {
|
||||||
};
|
};
|
||||||
|
|
||||||
static DerivedPathMap<StringSet>::ChildNode parseDerivedPathMapNode(
|
static DerivedPathMap<StringSet>::ChildNode parseDerivedPathMapNode(
|
||||||
const Store & store,
|
const StoreDirConfig & store,
|
||||||
std::istringstream & str,
|
std::istringstream & str,
|
||||||
DerivationATermVersion version)
|
DerivationATermVersion version)
|
||||||
{
|
{
|
||||||
|
@ -337,7 +337,7 @@ static DerivedPathMap<StringSet>::ChildNode parseDerivedPathMapNode(
|
||||||
|
|
||||||
|
|
||||||
Derivation parseDerivation(
|
Derivation parseDerivation(
|
||||||
const Store & store, std::string && s, std::string_view name,
|
const StoreDirConfig & store, std::string && s, std::string_view name,
|
||||||
const ExperimentalFeatureSettings & xpSettings)
|
const ExperimentalFeatureSettings & xpSettings)
|
||||||
{
|
{
|
||||||
Derivation drv;
|
Derivation drv;
|
||||||
|
@ -470,7 +470,7 @@ static void printUnquotedStrings(std::string & res, ForwardIterator i, ForwardIt
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void unparseDerivedPathMapNode(const Store & store, std::string & s, const DerivedPathMap<StringSet>::ChildNode & node)
|
static void unparseDerivedPathMapNode(const StoreDirConfig & store, std::string & s, const DerivedPathMap<StringSet>::ChildNode & node)
|
||||||
{
|
{
|
||||||
s += ',';
|
s += ',';
|
||||||
if (node.childMap.empty()) {
|
if (node.childMap.empty()) {
|
||||||
|
@ -511,7 +511,7 @@ static bool hasDynamicDrvDep(const Derivation & drv)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string Derivation::unparse(const Store & store, bool maskOutputs,
|
std::string Derivation::unparse(const StoreDirConfig & store, bool maskOutputs,
|
||||||
DerivedPathMap<StringSet>::ChildNode::Map * actualInputs) const
|
DerivedPathMap<StringSet>::ChildNode::Map * actualInputs) const
|
||||||
{
|
{
|
||||||
std::string s;
|
std::string s;
|
||||||
|
@ -845,7 +845,7 @@ std::map<std::string, Hash> staticOutputHashes(Store & store, const Derivation &
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static DerivationOutput readDerivationOutput(Source & in, const Store & store)
|
static DerivationOutput readDerivationOutput(Source & in, const StoreDirConfig & store)
|
||||||
{
|
{
|
||||||
const auto pathS = readString(in);
|
const auto pathS = readString(in);
|
||||||
const auto hashAlgo = readString(in);
|
const auto hashAlgo = readString(in);
|
||||||
|
@ -862,7 +862,7 @@ StringSet BasicDerivation::outputNames() const
|
||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
|
||||||
DerivationOutputsAndOptPaths BasicDerivation::outputsAndOptPaths(const Store & store) const
|
DerivationOutputsAndOptPaths BasicDerivation::outputsAndOptPaths(const StoreDirConfig & store) const
|
||||||
{
|
{
|
||||||
DerivationOutputsAndOptPaths outsAndOptPaths;
|
DerivationOutputsAndOptPaths outsAndOptPaths;
|
||||||
for (auto & [outputName, output] : outputs)
|
for (auto & [outputName, output] : outputs)
|
||||||
|
@ -884,7 +884,7 @@ std::string_view BasicDerivation::nameFromPath(const StorePath & drvPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Source & readDerivation(Source & in, const Store & store, BasicDerivation & drv, std::string_view name)
|
Source & readDerivation(Source & in, const StoreDirConfig & store, BasicDerivation & drv, std::string_view name)
|
||||||
{
|
{
|
||||||
drv.name = name;
|
drv.name = name;
|
||||||
|
|
||||||
|
@ -912,7 +912,7 @@ Source & readDerivation(Source & in, const Store & store, BasicDerivation & drv,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void writeDerivation(Sink & out, const Store & store, const BasicDerivation & drv)
|
void writeDerivation(Sink & out, const StoreDirConfig & store, const BasicDerivation & drv)
|
||||||
{
|
{
|
||||||
out << drv.outputs.size();
|
out << drv.outputs.size();
|
||||||
for (auto & i : drv.outputs) {
|
for (auto & i : drv.outputs) {
|
||||||
|
@ -1153,7 +1153,7 @@ void Derivation::checkInvariants(Store & store, const StorePath & drvPath) const
|
||||||
const Hash impureOutputHash = hashString(htSHA256, "impure");
|
const Hash impureOutputHash = hashString(htSHA256, "impure");
|
||||||
|
|
||||||
nlohmann::json DerivationOutput::toJSON(
|
nlohmann::json DerivationOutput::toJSON(
|
||||||
const Store & store, std::string_view drvName, OutputNameView outputName) const
|
const StoreDirConfig & store, std::string_view drvName, OutputNameView outputName) const
|
||||||
{
|
{
|
||||||
nlohmann::json res = nlohmann::json::object();
|
nlohmann::json res = nlohmann::json::object();
|
||||||
std::visit(overloaded {
|
std::visit(overloaded {
|
||||||
|
@ -1180,7 +1180,7 @@ nlohmann::json DerivationOutput::toJSON(
|
||||||
|
|
||||||
|
|
||||||
DerivationOutput DerivationOutput::fromJSON(
|
DerivationOutput DerivationOutput::fromJSON(
|
||||||
const Store & store, std::string_view drvName, OutputNameView outputName,
|
const StoreDirConfig & store, std::string_view drvName, OutputNameView outputName,
|
||||||
const nlohmann::json & _json,
|
const nlohmann::json & _json,
|
||||||
const ExperimentalFeatureSettings & xpSettings)
|
const ExperimentalFeatureSettings & xpSettings)
|
||||||
{
|
{
|
||||||
|
@ -1249,7 +1249,7 @@ DerivationOutput DerivationOutput::fromJSON(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
nlohmann::json Derivation::toJSON(const Store & store) const
|
nlohmann::json Derivation::toJSON(const StoreDirConfig & store) const
|
||||||
{
|
{
|
||||||
nlohmann::json res = nlohmann::json::object();
|
nlohmann::json res = nlohmann::json::object();
|
||||||
|
|
||||||
|
@ -1302,7 +1302,7 @@ nlohmann::json Derivation::toJSON(const Store & store) const
|
||||||
|
|
||||||
|
|
||||||
Derivation Derivation::fromJSON(
|
Derivation Derivation::fromJSON(
|
||||||
const Store & store,
|
const StoreDirConfig & store,
|
||||||
const nlohmann::json & json,
|
const nlohmann::json & json,
|
||||||
const ExperimentalFeatureSettings & xpSettings)
|
const ExperimentalFeatureSettings & xpSettings)
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
class Store;
|
struct StoreDirConfig;
|
||||||
|
|
||||||
/* Abstract syntax of derivations. */
|
/* Abstract syntax of derivations. */
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ struct DerivationOutput
|
||||||
* @param drvName The name of the derivation this is an output of, without the `.drv`.
|
* @param drvName The name of the derivation this is an output of, without the `.drv`.
|
||||||
* @param outputName The name of this output.
|
* @param outputName The name of this output.
|
||||||
*/
|
*/
|
||||||
StorePath path(const Store & store, std::string_view drvName, OutputNameView outputName) const;
|
StorePath path(const StoreDirConfig & store, std::string_view drvName, OutputNameView outputName) const;
|
||||||
|
|
||||||
GENERATE_CMP(CAFixed, me->ca);
|
GENERATE_CMP(CAFixed, me->ca);
|
||||||
};
|
};
|
||||||
|
@ -132,17 +132,17 @@ struct DerivationOutput
|
||||||
* the safer interface provided by
|
* the safer interface provided by
|
||||||
* BasicDerivation::outputsAndOptPaths
|
* BasicDerivation::outputsAndOptPaths
|
||||||
*/
|
*/
|
||||||
std::optional<StorePath> path(const Store & store, std::string_view drvName, OutputNameView outputName) const;
|
std::optional<StorePath> path(const StoreDirConfig & store, std::string_view drvName, OutputNameView outputName) const;
|
||||||
|
|
||||||
nlohmann::json toJSON(
|
nlohmann::json toJSON(
|
||||||
const Store & store,
|
const StoreDirConfig & store,
|
||||||
std::string_view drvName,
|
std::string_view drvName,
|
||||||
OutputNameView outputName) const;
|
OutputNameView outputName) const;
|
||||||
/**
|
/**
|
||||||
* @param xpSettings Stop-gap to avoid globals during unit tests.
|
* @param xpSettings Stop-gap to avoid globals during unit tests.
|
||||||
*/
|
*/
|
||||||
static DerivationOutput fromJSON(
|
static DerivationOutput fromJSON(
|
||||||
const Store & store,
|
const StoreDirConfig & store,
|
||||||
std::string_view drvName,
|
std::string_view drvName,
|
||||||
OutputNameView outputName,
|
OutputNameView outputName,
|
||||||
const nlohmann::json & json,
|
const nlohmann::json & json,
|
||||||
|
@ -304,7 +304,7 @@ struct BasicDerivation
|
||||||
* augmented with knowledge of the Store paths they would be written
|
* augmented with knowledge of the Store paths they would be written
|
||||||
* into.
|
* into.
|
||||||
*/
|
*/
|
||||||
DerivationOutputsAndOptPaths outputsAndOptPaths(const Store & store) const;
|
DerivationOutputsAndOptPaths outputsAndOptPaths(const StoreDirConfig & store) const;
|
||||||
|
|
||||||
static std::string_view nameFromPath(const StorePath & storePath);
|
static std::string_view nameFromPath(const StorePath & storePath);
|
||||||
|
|
||||||
|
@ -318,6 +318,8 @@ struct BasicDerivation
|
||||||
me->name);
|
me->name);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class Store;
|
||||||
|
|
||||||
struct Derivation : BasicDerivation
|
struct Derivation : BasicDerivation
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -328,7 +330,7 @@ struct Derivation : BasicDerivation
|
||||||
/**
|
/**
|
||||||
* Print a derivation.
|
* Print a derivation.
|
||||||
*/
|
*/
|
||||||
std::string unparse(const Store & store, bool maskOutputs,
|
std::string unparse(const StoreDirConfig & store, bool maskOutputs,
|
||||||
DerivedPathMap<StringSet>::ChildNode::Map * actualInputs = nullptr) const;
|
DerivedPathMap<StringSet>::ChildNode::Map * actualInputs = nullptr) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -365,9 +367,9 @@ struct Derivation : BasicDerivation
|
||||||
Derivation(const BasicDerivation & bd) : BasicDerivation(bd) { }
|
Derivation(const BasicDerivation & bd) : BasicDerivation(bd) { }
|
||||||
Derivation(BasicDerivation && bd) : BasicDerivation(std::move(bd)) { }
|
Derivation(BasicDerivation && bd) : BasicDerivation(std::move(bd)) { }
|
||||||
|
|
||||||
nlohmann::json toJSON(const Store & store) const;
|
nlohmann::json toJSON(const StoreDirConfig & store) const;
|
||||||
static Derivation fromJSON(
|
static Derivation fromJSON(
|
||||||
const Store & store,
|
const StoreDirConfig & store,
|
||||||
const nlohmann::json & json,
|
const nlohmann::json & json,
|
||||||
const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings);
|
const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings);
|
||||||
|
|
||||||
|
@ -391,7 +393,7 @@ StorePath writeDerivation(Store & store,
|
||||||
* Read a derivation from a file.
|
* Read a derivation from a file.
|
||||||
*/
|
*/
|
||||||
Derivation parseDerivation(
|
Derivation parseDerivation(
|
||||||
const Store & store,
|
const StoreDirConfig & store,
|
||||||
std::string && s,
|
std::string && s,
|
||||||
std::string_view name,
|
std::string_view name,
|
||||||
const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings);
|
const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings);
|
||||||
|
@ -493,8 +495,8 @@ extern Sync<DrvHashes> drvHashes;
|
||||||
struct Source;
|
struct Source;
|
||||||
struct Sink;
|
struct Sink;
|
||||||
|
|
||||||
Source & readDerivation(Source & in, const Store & store, BasicDerivation & drv, std::string_view name);
|
Source & readDerivation(Source & in, const StoreDirConfig & store, BasicDerivation & drv, std::string_view name);
|
||||||
void writeDerivation(Sink & out, const Store & store, const BasicDerivation & drv);
|
void writeDerivation(Sink & out, const StoreDirConfig & store, const BasicDerivation & drv);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This creates an opaque and almost certainly unique string
|
* This creates an opaque and almost certainly unique string
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "derived-path.hh"
|
#include "derived-path.hh"
|
||||||
|
#include "derivations.hh"
|
||||||
#include "store-api.hh"
|
#include "store-api.hh"
|
||||||
|
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
@ -32,7 +33,7 @@ CMP(SingleDerivedPath, DerivedPathBuilt, outputs)
|
||||||
#undef CMP
|
#undef CMP
|
||||||
#undef CMP_ONE
|
#undef CMP_ONE
|
||||||
|
|
||||||
nlohmann::json DerivedPath::Opaque::toJSON(const Store & store) const
|
nlohmann::json DerivedPath::Opaque::toJSON(const StoreDirConfig & store) const
|
||||||
{
|
{
|
||||||
return store.printStorePath(path);
|
return store.printStorePath(path);
|
||||||
}
|
}
|
||||||
|
@ -86,50 +87,50 @@ nlohmann::json DerivedPath::toJSON(Store & store) const
|
||||||
}, raw());
|
}, raw());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string DerivedPath::Opaque::to_string(const Store & store) const
|
std::string DerivedPath::Opaque::to_string(const StoreDirConfig & store) const
|
||||||
{
|
{
|
||||||
return store.printStorePath(path);
|
return store.printStorePath(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string SingleDerivedPath::Built::to_string(const Store & store) const
|
std::string SingleDerivedPath::Built::to_string(const StoreDirConfig & store) const
|
||||||
{
|
{
|
||||||
return drvPath->to_string(store) + "^" + output;
|
return drvPath->to_string(store) + "^" + output;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string SingleDerivedPath::Built::to_string_legacy(const Store & store) const
|
std::string SingleDerivedPath::Built::to_string_legacy(const StoreDirConfig & store) const
|
||||||
{
|
{
|
||||||
return drvPath->to_string(store) + "!" + output;
|
return drvPath->to_string(store) + "!" + output;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string DerivedPath::Built::to_string(const Store & store) const
|
std::string DerivedPath::Built::to_string(const StoreDirConfig & store) const
|
||||||
{
|
{
|
||||||
return drvPath->to_string(store)
|
return drvPath->to_string(store)
|
||||||
+ '^'
|
+ '^'
|
||||||
+ outputs.to_string();
|
+ outputs.to_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string DerivedPath::Built::to_string_legacy(const Store & store) const
|
std::string DerivedPath::Built::to_string_legacy(const StoreDirConfig & store) const
|
||||||
{
|
{
|
||||||
return drvPath->to_string_legacy(store)
|
return drvPath->to_string_legacy(store)
|
||||||
+ "!"
|
+ "!"
|
||||||
+ outputs.to_string();
|
+ outputs.to_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string SingleDerivedPath::to_string(const Store & store) const
|
std::string SingleDerivedPath::to_string(const StoreDirConfig & store) const
|
||||||
{
|
{
|
||||||
return std::visit(
|
return std::visit(
|
||||||
[&](const auto & req) { return req.to_string(store); },
|
[&](const auto & req) { return req.to_string(store); },
|
||||||
raw());
|
raw());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string DerivedPath::to_string(const Store & store) const
|
std::string DerivedPath::to_string(const StoreDirConfig & store) const
|
||||||
{
|
{
|
||||||
return std::visit(
|
return std::visit(
|
||||||
[&](const auto & req) { return req.to_string(store); },
|
[&](const auto & req) { return req.to_string(store); },
|
||||||
raw());
|
raw());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string SingleDerivedPath::to_string_legacy(const Store & store) const
|
std::string SingleDerivedPath::to_string_legacy(const StoreDirConfig & store) const
|
||||||
{
|
{
|
||||||
return std::visit(overloaded {
|
return std::visit(overloaded {
|
||||||
[&](const SingleDerivedPath::Built & req) { return req.to_string_legacy(store); },
|
[&](const SingleDerivedPath::Built & req) { return req.to_string_legacy(store); },
|
||||||
|
@ -137,7 +138,7 @@ std::string SingleDerivedPath::to_string_legacy(const Store & store) const
|
||||||
}, this->raw());
|
}, this->raw());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string DerivedPath::to_string_legacy(const Store & store) const
|
std::string DerivedPath::to_string_legacy(const StoreDirConfig & store) const
|
||||||
{
|
{
|
||||||
return std::visit(overloaded {
|
return std::visit(overloaded {
|
||||||
[&](const DerivedPath::Built & req) { return req.to_string_legacy(store); },
|
[&](const DerivedPath::Built & req) { return req.to_string_legacy(store); },
|
||||||
|
@ -146,7 +147,7 @@ std::string DerivedPath::to_string_legacy(const Store & store) const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DerivedPath::Opaque DerivedPath::Opaque::parse(const Store & store, std::string_view s)
|
DerivedPath::Opaque DerivedPath::Opaque::parse(const StoreDirConfig & store, std::string_view s)
|
||||||
{
|
{
|
||||||
return {store.parseStorePath(s)};
|
return {store.parseStorePath(s)};
|
||||||
}
|
}
|
||||||
|
@ -166,7 +167,7 @@ void drvRequireExperiment(
|
||||||
}
|
}
|
||||||
|
|
||||||
SingleDerivedPath::Built SingleDerivedPath::Built::parse(
|
SingleDerivedPath::Built SingleDerivedPath::Built::parse(
|
||||||
const Store & store, ref<SingleDerivedPath> drv,
|
const StoreDirConfig & store, ref<SingleDerivedPath> drv,
|
||||||
OutputNameView output,
|
OutputNameView output,
|
||||||
const ExperimentalFeatureSettings & xpSettings)
|
const ExperimentalFeatureSettings & xpSettings)
|
||||||
{
|
{
|
||||||
|
@ -178,7 +179,7 @@ SingleDerivedPath::Built SingleDerivedPath::Built::parse(
|
||||||
}
|
}
|
||||||
|
|
||||||
DerivedPath::Built DerivedPath::Built::parse(
|
DerivedPath::Built DerivedPath::Built::parse(
|
||||||
const Store & store, ref<SingleDerivedPath> drv,
|
const StoreDirConfig & store, ref<SingleDerivedPath> drv,
|
||||||
OutputNameView outputsS,
|
OutputNameView outputsS,
|
||||||
const ExperimentalFeatureSettings & xpSettings)
|
const ExperimentalFeatureSettings & xpSettings)
|
||||||
{
|
{
|
||||||
|
@ -190,7 +191,7 @@ DerivedPath::Built DerivedPath::Built::parse(
|
||||||
}
|
}
|
||||||
|
|
||||||
static SingleDerivedPath parseWithSingle(
|
static SingleDerivedPath parseWithSingle(
|
||||||
const Store & store, std::string_view s, std::string_view separator,
|
const StoreDirConfig & store, std::string_view s, std::string_view separator,
|
||||||
const ExperimentalFeatureSettings & xpSettings)
|
const ExperimentalFeatureSettings & xpSettings)
|
||||||
{
|
{
|
||||||
size_t n = s.rfind(separator);
|
size_t n = s.rfind(separator);
|
||||||
|
@ -207,7 +208,7 @@ static SingleDerivedPath parseWithSingle(
|
||||||
}
|
}
|
||||||
|
|
||||||
SingleDerivedPath SingleDerivedPath::parse(
|
SingleDerivedPath SingleDerivedPath::parse(
|
||||||
const Store & store,
|
const StoreDirConfig & store,
|
||||||
std::string_view s,
|
std::string_view s,
|
||||||
const ExperimentalFeatureSettings & xpSettings)
|
const ExperimentalFeatureSettings & xpSettings)
|
||||||
{
|
{
|
||||||
|
@ -215,7 +216,7 @@ SingleDerivedPath SingleDerivedPath::parse(
|
||||||
}
|
}
|
||||||
|
|
||||||
SingleDerivedPath SingleDerivedPath::parseLegacy(
|
SingleDerivedPath SingleDerivedPath::parseLegacy(
|
||||||
const Store & store,
|
const StoreDirConfig & store,
|
||||||
std::string_view s,
|
std::string_view s,
|
||||||
const ExperimentalFeatureSettings & xpSettings)
|
const ExperimentalFeatureSettings & xpSettings)
|
||||||
{
|
{
|
||||||
|
@ -223,7 +224,7 @@ SingleDerivedPath SingleDerivedPath::parseLegacy(
|
||||||
}
|
}
|
||||||
|
|
||||||
static DerivedPath parseWith(
|
static DerivedPath parseWith(
|
||||||
const Store & store, std::string_view s, std::string_view separator,
|
const StoreDirConfig & store, std::string_view s, std::string_view separator,
|
||||||
const ExperimentalFeatureSettings & xpSettings)
|
const ExperimentalFeatureSettings & xpSettings)
|
||||||
{
|
{
|
||||||
size_t n = s.rfind(separator);
|
size_t n = s.rfind(separator);
|
||||||
|
@ -240,7 +241,7 @@ static DerivedPath parseWith(
|
||||||
}
|
}
|
||||||
|
|
||||||
DerivedPath DerivedPath::parse(
|
DerivedPath DerivedPath::parse(
|
||||||
const Store & store,
|
const StoreDirConfig & store,
|
||||||
std::string_view s,
|
std::string_view s,
|
||||||
const ExperimentalFeatureSettings & xpSettings)
|
const ExperimentalFeatureSettings & xpSettings)
|
||||||
{
|
{
|
||||||
|
@ -248,7 +249,7 @@ DerivedPath DerivedPath::parse(
|
||||||
}
|
}
|
||||||
|
|
||||||
DerivedPath DerivedPath::parseLegacy(
|
DerivedPath DerivedPath::parseLegacy(
|
||||||
const Store & store,
|
const StoreDirConfig & store,
|
||||||
std::string_view s,
|
std::string_view s,
|
||||||
const ExperimentalFeatureSettings & xpSettings)
|
const ExperimentalFeatureSettings & xpSettings)
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,6 +12,9 @@
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
|
struct StoreDirConfig;
|
||||||
|
|
||||||
|
// TODO stop needing this, `toJSON` below should be pure
|
||||||
class Store;
|
class Store;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -24,9 +27,9 @@ class Store;
|
||||||
struct DerivedPathOpaque {
|
struct DerivedPathOpaque {
|
||||||
StorePath path;
|
StorePath path;
|
||||||
|
|
||||||
std::string to_string(const Store & store) const;
|
std::string to_string(const StoreDirConfig & store) const;
|
||||||
static DerivedPathOpaque parse(const Store & store, std::string_view);
|
static DerivedPathOpaque parse(const StoreDirConfig & store, std::string_view);
|
||||||
nlohmann::json toJSON(const Store & store) const;
|
nlohmann::json toJSON(const StoreDirConfig & store) const;
|
||||||
|
|
||||||
GENERATE_CMP(DerivedPathOpaque, me->path);
|
GENERATE_CMP(DerivedPathOpaque, me->path);
|
||||||
};
|
};
|
||||||
|
@ -59,18 +62,18 @@ struct SingleDerivedPathBuilt {
|
||||||
/**
|
/**
|
||||||
* Uses `^` as the separator
|
* Uses `^` as the separator
|
||||||
*/
|
*/
|
||||||
std::string to_string(const Store & store) const;
|
std::string to_string(const StoreDirConfig & store) const;
|
||||||
/**
|
/**
|
||||||
* Uses `!` as the separator
|
* Uses `!` as the separator
|
||||||
*/
|
*/
|
||||||
std::string to_string_legacy(const Store & store) const;
|
std::string to_string_legacy(const StoreDirConfig & store) const;
|
||||||
/**
|
/**
|
||||||
* The caller splits on the separator, so it works for both variants.
|
* The caller splits on the separator, so it works for both variants.
|
||||||
*
|
*
|
||||||
* @param xpSettings Stop-gap to avoid globals during unit tests.
|
* @param xpSettings Stop-gap to avoid globals during unit tests.
|
||||||
*/
|
*/
|
||||||
static SingleDerivedPathBuilt parse(
|
static SingleDerivedPathBuilt parse(
|
||||||
const Store & store, ref<SingleDerivedPath> drvPath,
|
const StoreDirConfig & store, ref<SingleDerivedPath> drvPath,
|
||||||
OutputNameView outputs,
|
OutputNameView outputs,
|
||||||
const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings);
|
const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings);
|
||||||
nlohmann::json toJSON(Store & store) const;
|
nlohmann::json toJSON(Store & store) const;
|
||||||
|
@ -120,18 +123,18 @@ struct SingleDerivedPath : _SingleDerivedPathRaw {
|
||||||
/**
|
/**
|
||||||
* Uses `^` as the separator
|
* Uses `^` as the separator
|
||||||
*/
|
*/
|
||||||
std::string to_string(const Store & store) const;
|
std::string to_string(const StoreDirConfig & store) const;
|
||||||
/**
|
/**
|
||||||
* Uses `!` as the separator
|
* Uses `!` as the separator
|
||||||
*/
|
*/
|
||||||
std::string to_string_legacy(const Store & store) const;
|
std::string to_string_legacy(const StoreDirConfig & store) const;
|
||||||
/**
|
/**
|
||||||
* Uses `^` as the separator
|
* Uses `^` as the separator
|
||||||
*
|
*
|
||||||
* @param xpSettings Stop-gap to avoid globals during unit tests.
|
* @param xpSettings Stop-gap to avoid globals during unit tests.
|
||||||
*/
|
*/
|
||||||
static SingleDerivedPath parse(
|
static SingleDerivedPath parse(
|
||||||
const Store & store,
|
const StoreDirConfig & store,
|
||||||
std::string_view,
|
std::string_view,
|
||||||
const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings);
|
const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings);
|
||||||
/**
|
/**
|
||||||
|
@ -140,7 +143,7 @@ struct SingleDerivedPath : _SingleDerivedPathRaw {
|
||||||
* @param xpSettings Stop-gap to avoid globals during unit tests.
|
* @param xpSettings Stop-gap to avoid globals during unit tests.
|
||||||
*/
|
*/
|
||||||
static SingleDerivedPath parseLegacy(
|
static SingleDerivedPath parseLegacy(
|
||||||
const Store & store,
|
const StoreDirConfig & store,
|
||||||
std::string_view,
|
std::string_view,
|
||||||
const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings);
|
const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings);
|
||||||
nlohmann::json toJSON(Store & store) const;
|
nlohmann::json toJSON(Store & store) const;
|
||||||
|
@ -182,18 +185,18 @@ struct DerivedPathBuilt {
|
||||||
/**
|
/**
|
||||||
* Uses `^` as the separator
|
* Uses `^` as the separator
|
||||||
*/
|
*/
|
||||||
std::string to_string(const Store & store) const;
|
std::string to_string(const StoreDirConfig & store) const;
|
||||||
/**
|
/**
|
||||||
* Uses `!` as the separator
|
* Uses `!` as the separator
|
||||||
*/
|
*/
|
||||||
std::string to_string_legacy(const Store & store) const;
|
std::string to_string_legacy(const StoreDirConfig & store) const;
|
||||||
/**
|
/**
|
||||||
* The caller splits on the separator, so it works for both variants.
|
* The caller splits on the separator, so it works for both variants.
|
||||||
*
|
*
|
||||||
* @param xpSettings Stop-gap to avoid globals during unit tests.
|
* @param xpSettings Stop-gap to avoid globals during unit tests.
|
||||||
*/
|
*/
|
||||||
static DerivedPathBuilt parse(
|
static DerivedPathBuilt parse(
|
||||||
const Store & store, ref<SingleDerivedPath>,
|
const StoreDirConfig & store, ref<SingleDerivedPath>,
|
||||||
std::string_view,
|
std::string_view,
|
||||||
const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings);
|
const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings);
|
||||||
nlohmann::json toJSON(Store & store) const;
|
nlohmann::json toJSON(Store & store) const;
|
||||||
|
@ -242,18 +245,18 @@ struct DerivedPath : _DerivedPathRaw {
|
||||||
/**
|
/**
|
||||||
* Uses `^` as the separator
|
* Uses `^` as the separator
|
||||||
*/
|
*/
|
||||||
std::string to_string(const Store & store) const;
|
std::string to_string(const StoreDirConfig & store) const;
|
||||||
/**
|
/**
|
||||||
* Uses `!` as the separator
|
* Uses `!` as the separator
|
||||||
*/
|
*/
|
||||||
std::string to_string_legacy(const Store & store) const;
|
std::string to_string_legacy(const StoreDirConfig & store) const;
|
||||||
/**
|
/**
|
||||||
* Uses `^` as the separator
|
* Uses `^` as the separator
|
||||||
*
|
*
|
||||||
* @param xpSettings Stop-gap to avoid globals during unit tests.
|
* @param xpSettings Stop-gap to avoid globals during unit tests.
|
||||||
*/
|
*/
|
||||||
static DerivedPath parse(
|
static DerivedPath parse(
|
||||||
const Store & store,
|
const StoreDirConfig & store,
|
||||||
std::string_view,
|
std::string_view,
|
||||||
const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings);
|
const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings);
|
||||||
/**
|
/**
|
||||||
|
@ -262,7 +265,7 @@ struct DerivedPath : _DerivedPathRaw {
|
||||||
* @param xpSettings Stop-gap to avoid globals during unit tests.
|
* @param xpSettings Stop-gap to avoid globals during unit tests.
|
||||||
*/
|
*/
|
||||||
static DerivedPath parseLegacy(
|
static DerivedPath parseLegacy(
|
||||||
const Store & store,
|
const StoreDirConfig & store,
|
||||||
std::string_view,
|
std::string_view,
|
||||||
const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings);
|
const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings);
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
class Store;
|
struct StoreDirConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reusable serialisers for serialization container types in a
|
* Reusable serialisers for serialization container types in a
|
||||||
|
@ -44,8 +44,8 @@ struct LengthPrefixedProtoHelper;
|
||||||
#define LENGTH_PREFIXED_PROTO_HELPER(Inner, T) \
|
#define LENGTH_PREFIXED_PROTO_HELPER(Inner, T) \
|
||||||
struct LengthPrefixedProtoHelper< Inner, T > \
|
struct LengthPrefixedProtoHelper< Inner, T > \
|
||||||
{ \
|
{ \
|
||||||
static T read(const Store & store, typename Inner::ReadConn conn); \
|
static T read(const StoreDirConfig & store, typename Inner::ReadConn conn); \
|
||||||
static void write(const Store & store, typename Inner::WriteConn conn, const T & str); \
|
static void write(const StoreDirConfig & store, typename Inner::WriteConn conn, const T & str); \
|
||||||
private: \
|
private: \
|
||||||
template<typename U> using S = typename Inner::template Serialise<U>; \
|
template<typename U> using S = typename Inner::template Serialise<U>; \
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ LENGTH_PREFIXED_PROTO_HELPER(Inner, _X);
|
||||||
template<class Inner, typename T>
|
template<class Inner, typename T>
|
||||||
std::vector<T>
|
std::vector<T>
|
||||||
LengthPrefixedProtoHelper<Inner, std::vector<T>>::read(
|
LengthPrefixedProtoHelper<Inner, std::vector<T>>::read(
|
||||||
const Store & store, typename Inner::ReadConn conn)
|
const StoreDirConfig & store, typename Inner::ReadConn conn)
|
||||||
{
|
{
|
||||||
std::vector<T> resSet;
|
std::vector<T> resSet;
|
||||||
auto size = readNum<size_t>(conn.from);
|
auto size = readNum<size_t>(conn.from);
|
||||||
|
@ -80,7 +80,7 @@ LengthPrefixedProtoHelper<Inner, std::vector<T>>::read(
|
||||||
template<class Inner, typename T>
|
template<class Inner, typename T>
|
||||||
void
|
void
|
||||||
LengthPrefixedProtoHelper<Inner, std::vector<T>>::write(
|
LengthPrefixedProtoHelper<Inner, std::vector<T>>::write(
|
||||||
const Store & store, typename Inner::WriteConn conn, const std::vector<T> & resSet)
|
const StoreDirConfig & store, typename Inner::WriteConn conn, const std::vector<T> & resSet)
|
||||||
{
|
{
|
||||||
conn.to << resSet.size();
|
conn.to << resSet.size();
|
||||||
for (auto & key : resSet) {
|
for (auto & key : resSet) {
|
||||||
|
@ -91,7 +91,7 @@ LengthPrefixedProtoHelper<Inner, std::vector<T>>::write(
|
||||||
template<class Inner, typename T>
|
template<class Inner, typename T>
|
||||||
std::set<T>
|
std::set<T>
|
||||||
LengthPrefixedProtoHelper<Inner, std::set<T>>::read(
|
LengthPrefixedProtoHelper<Inner, std::set<T>>::read(
|
||||||
const Store & store, typename Inner::ReadConn conn)
|
const StoreDirConfig & store, typename Inner::ReadConn conn)
|
||||||
{
|
{
|
||||||
std::set<T> resSet;
|
std::set<T> resSet;
|
||||||
auto size = readNum<size_t>(conn.from);
|
auto size = readNum<size_t>(conn.from);
|
||||||
|
@ -104,7 +104,7 @@ LengthPrefixedProtoHelper<Inner, std::set<T>>::read(
|
||||||
template<class Inner, typename T>
|
template<class Inner, typename T>
|
||||||
void
|
void
|
||||||
LengthPrefixedProtoHelper<Inner, std::set<T>>::write(
|
LengthPrefixedProtoHelper<Inner, std::set<T>>::write(
|
||||||
const Store & store, typename Inner::WriteConn conn, const std::set<T> & resSet)
|
const StoreDirConfig & store, typename Inner::WriteConn conn, const std::set<T> & resSet)
|
||||||
{
|
{
|
||||||
conn.to << resSet.size();
|
conn.to << resSet.size();
|
||||||
for (auto & key : resSet) {
|
for (auto & key : resSet) {
|
||||||
|
@ -115,7 +115,7 @@ LengthPrefixedProtoHelper<Inner, std::set<T>>::write(
|
||||||
template<class Inner, typename K, typename V>
|
template<class Inner, typename K, typename V>
|
||||||
std::map<K, V>
|
std::map<K, V>
|
||||||
LengthPrefixedProtoHelper<Inner, std::map<K, V>>::read(
|
LengthPrefixedProtoHelper<Inner, std::map<K, V>>::read(
|
||||||
const Store & store, typename Inner::ReadConn conn)
|
const StoreDirConfig & store, typename Inner::ReadConn conn)
|
||||||
{
|
{
|
||||||
std::map<K, V> resMap;
|
std::map<K, V> resMap;
|
||||||
auto size = readNum<size_t>(conn.from);
|
auto size = readNum<size_t>(conn.from);
|
||||||
|
@ -130,7 +130,7 @@ LengthPrefixedProtoHelper<Inner, std::map<K, V>>::read(
|
||||||
template<class Inner, typename K, typename V>
|
template<class Inner, typename K, typename V>
|
||||||
void
|
void
|
||||||
LengthPrefixedProtoHelper<Inner, std::map<K, V>>::write(
|
LengthPrefixedProtoHelper<Inner, std::map<K, V>>::write(
|
||||||
const Store & store, typename Inner::WriteConn conn, const std::map<K, V> & resMap)
|
const StoreDirConfig & store, typename Inner::WriteConn conn, const std::map<K, V> & resMap)
|
||||||
{
|
{
|
||||||
conn.to << resMap.size();
|
conn.to << resMap.size();
|
||||||
for (auto & i : resMap) {
|
for (auto & i : resMap) {
|
||||||
|
@ -142,7 +142,7 @@ LengthPrefixedProtoHelper<Inner, std::map<K, V>>::write(
|
||||||
template<class Inner, typename... Ts>
|
template<class Inner, typename... Ts>
|
||||||
std::tuple<Ts...>
|
std::tuple<Ts...>
|
||||||
LengthPrefixedProtoHelper<Inner, std::tuple<Ts...>>::read(
|
LengthPrefixedProtoHelper<Inner, std::tuple<Ts...>>::read(
|
||||||
const Store & store, typename Inner::ReadConn conn)
|
const StoreDirConfig & store, typename Inner::ReadConn conn)
|
||||||
{
|
{
|
||||||
return std::tuple<Ts...> {
|
return std::tuple<Ts...> {
|
||||||
S<Ts>::read(store, conn)...,
|
S<Ts>::read(store, conn)...,
|
||||||
|
@ -152,7 +152,7 @@ LengthPrefixedProtoHelper<Inner, std::tuple<Ts...>>::read(
|
||||||
template<class Inner, typename... Ts>
|
template<class Inner, typename... Ts>
|
||||||
void
|
void
|
||||||
LengthPrefixedProtoHelper<Inner, std::tuple<Ts...>>::write(
|
LengthPrefixedProtoHelper<Inner, std::tuple<Ts...>>::write(
|
||||||
const Store & store, typename Inner::WriteConn conn, const std::tuple<Ts...> & res)
|
const StoreDirConfig & store, typename Inner::WriteConn conn, const std::tuple<Ts...> & res)
|
||||||
{
|
{
|
||||||
std::apply([&]<typename... Us>(const Us &... args) {
|
std::apply([&]<typename... Us>(const Us &... args) {
|
||||||
(S<Us>::write(store, conn, args), ...);
|
(S<Us>::write(store, conn, args), ...);
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include "pathlocks.hh"
|
#include "pathlocks.hh"
|
||||||
#include "worker-protocol.hh"
|
#include "worker-protocol.hh"
|
||||||
#include "derivations.hh"
|
#include "derivations.hh"
|
||||||
|
#include "realisation.hh"
|
||||||
#include "nar-info.hh"
|
#include "nar-info.hh"
|
||||||
#include "references.hh"
|
#include "references.hh"
|
||||||
#include "callback.hh"
|
#include "callback.hh"
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include "local-store.hh"
|
#include "local-store.hh"
|
||||||
#include "store-api.hh"
|
#include "store-api.hh"
|
||||||
#include "thread-pool.hh"
|
#include "thread-pool.hh"
|
||||||
|
#include "realisation.hh"
|
||||||
#include "topo-sort.hh"
|
#include "topo-sort.hh"
|
||||||
#include "callback.hh"
|
#include "callback.hh"
|
||||||
#include "closure.hh"
|
#include "closure.hh"
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
std::string StorePathWithOutputs::to_string(const Store & store) const
|
std::string StorePathWithOutputs::to_string(const StoreDirConfig & store) const
|
||||||
{
|
{
|
||||||
return outputs.empty()
|
return outputs.empty()
|
||||||
? store.printStorePath(path)
|
? store.printStorePath(path)
|
||||||
|
@ -85,7 +85,7 @@ std::pair<std::string_view, StringSet> parsePathWithOutputs(std::string_view s)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
StorePathWithOutputs parsePathWithOutputs(const Store & store, std::string_view pathWithOutputs)
|
StorePathWithOutputs parsePathWithOutputs(const StoreDirConfig & store, std::string_view pathWithOutputs)
|
||||||
{
|
{
|
||||||
auto [path, outputs] = parsePathWithOutputs(pathWithOutputs);
|
auto [path, outputs] = parsePathWithOutputs(pathWithOutputs);
|
||||||
return StorePathWithOutputs { store.parseStorePath(path), std::move(outputs) };
|
return StorePathWithOutputs { store.parseStorePath(path), std::move(outputs) };
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
|
struct StoreDirConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a deprecated old type just for use by the old CLI, and older
|
* This is a deprecated old type just for use by the old CLI, and older
|
||||||
* versions of the RPC protocols. In new code don't use it; you want
|
* versions of the RPC protocols. In new code don't use it; you want
|
||||||
|
@ -19,7 +21,7 @@ struct StorePathWithOutputs
|
||||||
StorePath path;
|
StorePath path;
|
||||||
std::set<std::string> outputs;
|
std::set<std::string> outputs;
|
||||||
|
|
||||||
std::string to_string(const Store & store) const;
|
std::string to_string(const StoreDirConfig & store) const;
|
||||||
|
|
||||||
DerivedPath toDerivedPath() const;
|
DerivedPath toDerivedPath() const;
|
||||||
|
|
||||||
|
@ -32,14 +34,14 @@ std::vector<DerivedPath> toDerivedPaths(const std::vector<StorePathWithOutputs>)
|
||||||
|
|
||||||
std::pair<std::string_view, StringSet> parsePathWithOutputs(std::string_view s);
|
std::pair<std::string_view, StringSet> parsePathWithOutputs(std::string_view s);
|
||||||
|
|
||||||
class Store;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Split a string specifying a derivation and a set of outputs
|
* Split a string specifying a derivation and a set of outputs
|
||||||
* (/nix/store/hash-foo!out1,out2,...) into the derivation path
|
* (/nix/store/hash-foo!out1,out2,...) into the derivation path
|
||||||
* and the outputs.
|
* and the outputs.
|
||||||
*/
|
*/
|
||||||
StorePathWithOutputs parsePathWithOutputs(const Store & store, std::string_view pathWithOutputs);
|
StorePathWithOutputs parsePathWithOutputs(const StoreDirConfig & store, std::string_view pathWithOutputs);
|
||||||
|
|
||||||
|
class Store;
|
||||||
|
|
||||||
StorePathWithOutputs followLinksToStorePathWithOutputs(const Store & store, std::string_view pathWithOutputs);
|
StorePathWithOutputs followLinksToStorePathWithOutputs(const Store & store, std::string_view pathWithOutputs);
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#include "store-api.hh"
|
#include "store-dir-config.hh"
|
||||||
|
|
||||||
#include <sodium.h>
|
#include <sodium.h>
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ StorePath StorePath::random(std::string_view name)
|
||||||
return StorePath(hash, name);
|
return StorePath(hash, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
StorePath Store::parseStorePath(std::string_view path) const
|
StorePath StoreDirConfig::parseStorePath(std::string_view path) const
|
||||||
{
|
{
|
||||||
auto p = canonPath(std::string(path));
|
auto p = canonPath(std::string(path));
|
||||||
if (dirOf(p) != storeDir)
|
if (dirOf(p) != storeDir)
|
||||||
|
@ -62,7 +62,7 @@ StorePath Store::parseStorePath(std::string_view path) const
|
||||||
return StorePath(baseNameOf(p));
|
return StorePath(baseNameOf(p));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<StorePath> Store::maybeParseStorePath(std::string_view path) const
|
std::optional<StorePath> StoreDirConfig::maybeParseStorePath(std::string_view path) const
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
return parseStorePath(path);
|
return parseStorePath(path);
|
||||||
|
@ -71,24 +71,24 @@ std::optional<StorePath> Store::maybeParseStorePath(std::string_view path) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Store::isStorePath(std::string_view path) const
|
bool StoreDirConfig::isStorePath(std::string_view path) const
|
||||||
{
|
{
|
||||||
return (bool) maybeParseStorePath(path);
|
return (bool) maybeParseStorePath(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
StorePathSet Store::parseStorePathSet(const PathSet & paths) const
|
StorePathSet StoreDirConfig::parseStorePathSet(const PathSet & paths) const
|
||||||
{
|
{
|
||||||
StorePathSet res;
|
StorePathSet res;
|
||||||
for (auto & i : paths) res.insert(parseStorePath(i));
|
for (auto & i : paths) res.insert(parseStorePath(i));
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Store::printStorePath(const StorePath & path) const
|
std::string StoreDirConfig::printStorePath(const StorePath & path) const
|
||||||
{
|
{
|
||||||
return (storeDir + "/").append(path.to_string());
|
return (storeDir + "/").append(path.to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
PathSet Store::printStorePathSet(const StorePathSet & paths) const
|
PathSet StoreDirConfig::printStorePathSet(const StorePathSet & paths) const
|
||||||
{
|
{
|
||||||
PathSet res;
|
PathSet res;
|
||||||
for (auto & i : paths) res.insert(printStorePath(i));
|
for (auto & i : paths) res.insert(printStorePath(i));
|
||||||
|
|
|
@ -16,11 +16,11 @@ namespace nix {
|
||||||
/* protocol-agnostic templates */
|
/* protocol-agnostic templates */
|
||||||
|
|
||||||
#define SERVE_USE_LENGTH_PREFIX_SERIALISER(TEMPLATE, T) \
|
#define SERVE_USE_LENGTH_PREFIX_SERIALISER(TEMPLATE, T) \
|
||||||
TEMPLATE T ServeProto::Serialise< T >::read(const Store & store, ServeProto::ReadConn conn) \
|
TEMPLATE T ServeProto::Serialise< T >::read(const StoreDirConfig & store, ServeProto::ReadConn conn) \
|
||||||
{ \
|
{ \
|
||||||
return LengthPrefixedProtoHelper<ServeProto, T >::read(store, conn); \
|
return LengthPrefixedProtoHelper<ServeProto, T >::read(store, conn); \
|
||||||
} \
|
} \
|
||||||
TEMPLATE void ServeProto::Serialise< T >::write(const Store & store, ServeProto::WriteConn conn, const T & t) \
|
TEMPLATE void ServeProto::Serialise< T >::write(const StoreDirConfig & store, ServeProto::WriteConn conn, const T & t) \
|
||||||
{ \
|
{ \
|
||||||
LengthPrefixedProtoHelper<ServeProto, T >::write(store, conn, t); \
|
LengthPrefixedProtoHelper<ServeProto, T >::write(store, conn, t); \
|
||||||
}
|
}
|
||||||
|
@ -41,12 +41,12 @@ SERVE_USE_LENGTH_PREFIX_SERIALISER(
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct ServeProto::Serialise
|
struct ServeProto::Serialise
|
||||||
{
|
{
|
||||||
static T read(const Store & store, ServeProto::ReadConn conn)
|
static T read(const StoreDirConfig & store, ServeProto::ReadConn conn)
|
||||||
{
|
{
|
||||||
return CommonProto::Serialise<T>::read(store,
|
return CommonProto::Serialise<T>::read(store,
|
||||||
CommonProto::ReadConn { .from = conn.from });
|
CommonProto::ReadConn { .from = conn.from });
|
||||||
}
|
}
|
||||||
static void write(const Store & store, ServeProto::WriteConn conn, const T & t)
|
static void write(const StoreDirConfig & store, ServeProto::WriteConn conn, const T & t)
|
||||||
{
|
{
|
||||||
CommonProto::Serialise<T>::write(store,
|
CommonProto::Serialise<T>::write(store,
|
||||||
CommonProto::WriteConn { .to = conn.to },
|
CommonProto::WriteConn { .to = conn.to },
|
||||||
|
|
|
@ -12,7 +12,7 @@ namespace nix {
|
||||||
|
|
||||||
/* protocol-specific definitions */
|
/* protocol-specific definitions */
|
||||||
|
|
||||||
BuildResult ServeProto::Serialise<BuildResult>::read(const Store & store, ServeProto::ReadConn conn)
|
BuildResult ServeProto::Serialise<BuildResult>::read(const StoreDirConfig & store, ServeProto::ReadConn conn)
|
||||||
{
|
{
|
||||||
BuildResult status;
|
BuildResult status;
|
||||||
status.status = (BuildResult::Status) readInt(conn.from);
|
status.status = (BuildResult::Status) readInt(conn.from);
|
||||||
|
@ -34,7 +34,7 @@ BuildResult ServeProto::Serialise<BuildResult>::read(const Store & store, ServeP
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServeProto::Serialise<BuildResult>::write(const Store & store, ServeProto::WriteConn conn, const BuildResult & status)
|
void ServeProto::Serialise<BuildResult>::write(const StoreDirConfig & store, ServeProto::WriteConn conn, const BuildResult & status)
|
||||||
{
|
{
|
||||||
conn.to
|
conn.to
|
||||||
<< status.status
|
<< status.status
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace nix {
|
||||||
#define GET_PROTOCOL_MINOR(x) ((x) & 0x00ff)
|
#define GET_PROTOCOL_MINOR(x) ((x) & 0x00ff)
|
||||||
|
|
||||||
|
|
||||||
class Store;
|
struct StoreDirConfig;
|
||||||
struct Source;
|
struct Source;
|
||||||
|
|
||||||
// items being serialised
|
// items being serialised
|
||||||
|
@ -72,8 +72,8 @@ struct ServeProto
|
||||||
// See `worker-protocol.hh` for a longer explanation.
|
// See `worker-protocol.hh` for a longer explanation.
|
||||||
#if 0
|
#if 0
|
||||||
{
|
{
|
||||||
static T read(const Store & store, ReadConn conn);
|
static T read(const StoreDirConfig & store, ReadConn conn);
|
||||||
static void write(const Store & store, WriteConn conn, const T & t);
|
static void write(const StoreDirConfig & store, WriteConn conn, const T & t);
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ struct ServeProto
|
||||||
* infer the type instead of having to write it down explicitly.
|
* infer the type instead of having to write it down explicitly.
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static void write(const Store & store, WriteConn conn, const T & t)
|
static void write(const StoreDirConfig & store, WriteConn conn, const T & t)
|
||||||
{
|
{
|
||||||
ServeProto::Serialise<T>::write(store, conn, t);
|
ServeProto::Serialise<T>::write(store, conn, t);
|
||||||
}
|
}
|
||||||
|
@ -135,8 +135,8 @@ inline std::ostream & operator << (std::ostream & s, ServeProto::Command op)
|
||||||
#define DECLARE_SERVE_SERIALISER(T) \
|
#define DECLARE_SERVE_SERIALISER(T) \
|
||||||
struct ServeProto::Serialise< T > \
|
struct ServeProto::Serialise< T > \
|
||||||
{ \
|
{ \
|
||||||
static T read(const Store & store, ServeProto::ReadConn conn); \
|
static T read(const StoreDirConfig & store, ServeProto::ReadConn conn); \
|
||||||
static void write(const Store & store, ServeProto::WriteConn conn, const T & t); \
|
static void write(const StoreDirConfig & store, ServeProto::WriteConn conn, const T & t); \
|
||||||
};
|
};
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#include "crypto.hh"
|
#include "crypto.hh"
|
||||||
#include "source-accessor.hh"
|
#include "source-accessor.hh"
|
||||||
#include "globals.hh"
|
#include "globals.hh"
|
||||||
|
#include "derived-path.hh"
|
||||||
|
#include "realisation.hh"
|
||||||
#include "derivations.hh"
|
#include "derivations.hh"
|
||||||
#include "store-api.hh"
|
#include "store-api.hh"
|
||||||
#include "util.hh"
|
#include "util.hh"
|
||||||
|
@ -25,13 +27,13 @@ using json = nlohmann::json;
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
|
|
||||||
bool Store::isInStore(PathView path) const
|
bool StoreDirConfig::isInStore(PathView path) const
|
||||||
{
|
{
|
||||||
return isInDir(path, storeDir);
|
return isInDir(path, storeDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::pair<StorePath, Path> Store::toStorePath(PathView path) const
|
std::pair<StorePath, Path> StoreDirConfig::toStorePath(PathView path) const
|
||||||
{
|
{
|
||||||
if (!isInStore(path))
|
if (!isInStore(path))
|
||||||
throw Error("path '%1%' is not in the Nix store", path);
|
throw Error("path '%1%' is not in the Nix store", path);
|
||||||
|
@ -145,7 +147,7 @@ StorePath Store::followLinksToStorePath(std::string_view path) const
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
StorePath Store::makeStorePath(std::string_view type,
|
StorePath StoreDirConfig::makeStorePath(std::string_view type,
|
||||||
std::string_view hash, std::string_view name) const
|
std::string_view hash, std::string_view name) const
|
||||||
{
|
{
|
||||||
/* e.g., "source:sha256:1abc...:/nix/store:foo.tar.gz" */
|
/* e.g., "source:sha256:1abc...:/nix/store:foo.tar.gz" */
|
||||||
|
@ -156,14 +158,14 @@ StorePath Store::makeStorePath(std::string_view type,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
StorePath Store::makeStorePath(std::string_view type,
|
StorePath StoreDirConfig::makeStorePath(std::string_view type,
|
||||||
const Hash & hash, std::string_view name) const
|
const Hash & hash, std::string_view name) const
|
||||||
{
|
{
|
||||||
return makeStorePath(type, hash.to_string(HashFormat::Base16, true), name);
|
return makeStorePath(type, hash.to_string(HashFormat::Base16, true), name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
StorePath Store::makeOutputPath(std::string_view id,
|
StorePath StoreDirConfig::makeOutputPath(std::string_view id,
|
||||||
const Hash & hash, std::string_view name) const
|
const Hash & hash, std::string_view name) const
|
||||||
{
|
{
|
||||||
return makeStorePath("output:" + std::string { id }, hash, outputPathName(name, id));
|
return makeStorePath("output:" + std::string { id }, hash, outputPathName(name, id));
|
||||||
|
@ -174,7 +176,7 @@ StorePath Store::makeOutputPath(std::string_view id,
|
||||||
hacky, but we can't put them in, say, <s2> (per the grammar above)
|
hacky, but we can't put them in, say, <s2> (per the grammar above)
|
||||||
since that would be ambiguous. */
|
since that would be ambiguous. */
|
||||||
static std::string makeType(
|
static std::string makeType(
|
||||||
const Store & store,
|
const StoreDirConfig & store,
|
||||||
std::string && type,
|
std::string && type,
|
||||||
const StoreReferences & references)
|
const StoreReferences & references)
|
||||||
{
|
{
|
||||||
|
@ -187,7 +189,7 @@ static std::string makeType(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
StorePath Store::makeFixedOutputPath(std::string_view name, const FixedOutputInfo & info) const
|
StorePath StoreDirConfig::makeFixedOutputPath(std::string_view name, const FixedOutputInfo & info) const
|
||||||
{
|
{
|
||||||
if (info.hash.type == htSHA256 && info.method == FileIngestionMethod::Recursive) {
|
if (info.hash.type == htSHA256 && info.method == FileIngestionMethod::Recursive) {
|
||||||
return makeStorePath(makeType(*this, "source", info.references), info.hash, name);
|
return makeStorePath(makeType(*this, "source", info.references), info.hash, name);
|
||||||
|
@ -203,7 +205,7 @@ StorePath Store::makeFixedOutputPath(std::string_view name, const FixedOutputInf
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
StorePath Store::makeTextPath(std::string_view name, const TextInfo & info) const
|
StorePath StoreDirConfig::makeTextPath(std::string_view name, const TextInfo & info) const
|
||||||
{
|
{
|
||||||
assert(info.hash.type == htSHA256);
|
assert(info.hash.type == htSHA256);
|
||||||
return makeStorePath(
|
return makeStorePath(
|
||||||
|
@ -216,7 +218,7 @@ StorePath Store::makeTextPath(std::string_view name, const TextInfo & info) cons
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
StorePath Store::makeFixedOutputPathFromCA(std::string_view name, const ContentAddressWithReferences & ca) const
|
StorePath StoreDirConfig::makeFixedOutputPathFromCA(std::string_view name, const ContentAddressWithReferences & ca) const
|
||||||
{
|
{
|
||||||
// New template
|
// New template
|
||||||
return std::visit(overloaded {
|
return std::visit(overloaded {
|
||||||
|
@ -230,7 +232,7 @@ StorePath Store::makeFixedOutputPathFromCA(std::string_view name, const ContentA
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::pair<StorePath, Hash> Store::computeStorePathFromDump(
|
std::pair<StorePath, Hash> StoreDirConfig::computeStorePathFromDump(
|
||||||
Source & dump,
|
Source & dump,
|
||||||
std::string_view name,
|
std::string_view name,
|
||||||
FileIngestionMethod method,
|
FileIngestionMethod method,
|
||||||
|
@ -249,7 +251,7 @@ std::pair<StorePath, Hash> Store::computeStorePathFromDump(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
StorePath Store::computeStorePathForText(
|
StorePath StoreDirConfig::computeStorePathForText(
|
||||||
std::string_view name,
|
std::string_view name,
|
||||||
std::string_view s,
|
std::string_view s,
|
||||||
const StorePathSet & references) const
|
const StorePathSet & references) const
|
||||||
|
@ -1227,7 +1229,7 @@ std::optional<ValidPathInfo> decodeValidPathInfo(const Store & store, std::istre
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string Store::showPaths(const StorePathSet & paths)
|
std::string StoreDirConfig::showPaths(const StorePathSet & paths)
|
||||||
{
|
{
|
||||||
std::string s;
|
std::string s;
|
||||||
for (auto & i : paths) {
|
for (auto & i : paths) {
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
///@file
|
///@file
|
||||||
|
|
||||||
#include "nar-info.hh"
|
|
||||||
#include "realisation.hh"
|
|
||||||
#include "path.hh"
|
#include "path.hh"
|
||||||
#include "derived-path.hh"
|
#include "derived-path.hh"
|
||||||
#include "hash.hh"
|
#include "hash.hh"
|
||||||
|
@ -14,6 +12,7 @@
|
||||||
#include "config.hh"
|
#include "config.hh"
|
||||||
#include "path-info.hh"
|
#include "path-info.hh"
|
||||||
#include "repair-flag.hh"
|
#include "repair-flag.hh"
|
||||||
|
#include "store-dir-config.hh"
|
||||||
|
|
||||||
#include <nlohmann/json_fwd.hpp>
|
#include <nlohmann/json_fwd.hpp>
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
|
@ -64,12 +63,16 @@ MakeError(InvalidPath, Error);
|
||||||
MakeError(Unsupported, Error);
|
MakeError(Unsupported, Error);
|
||||||
MakeError(SubstituteGone, Error);
|
MakeError(SubstituteGone, Error);
|
||||||
MakeError(SubstituterDisabled, Error);
|
MakeError(SubstituterDisabled, Error);
|
||||||
MakeError(BadStorePath, Error);
|
|
||||||
|
|
||||||
MakeError(InvalidStoreURI, Error);
|
MakeError(InvalidStoreURI, Error);
|
||||||
|
|
||||||
|
struct Realisation;
|
||||||
|
struct RealisedPath;
|
||||||
|
struct DrvOutput;
|
||||||
|
|
||||||
struct BasicDerivation;
|
struct BasicDerivation;
|
||||||
struct Derivation;
|
struct Derivation;
|
||||||
|
|
||||||
struct SourceAccessor;
|
struct SourceAccessor;
|
||||||
class NarInfoDiskCache;
|
class NarInfoDiskCache;
|
||||||
class Store;
|
class Store;
|
||||||
|
@ -96,11 +99,11 @@ struct KeyedBuildResult;
|
||||||
|
|
||||||
typedef std::map<StorePath, std::optional<ContentAddress>> StorePathCAMap;
|
typedef std::map<StorePath, std::optional<ContentAddress>> StorePathCAMap;
|
||||||
|
|
||||||
struct StoreConfig : public Config
|
struct StoreConfig : public StoreDirConfig
|
||||||
{
|
{
|
||||||
typedef std::map<std::string, std::string> Params;
|
typedef std::map<std::string, std::string> Params;
|
||||||
|
|
||||||
using Config::Config;
|
using StoreDirConfig::StoreDirConfig;
|
||||||
|
|
||||||
StoreConfig() = delete;
|
StoreConfig() = delete;
|
||||||
|
|
||||||
|
@ -130,15 +133,6 @@ struct StoreConfig : public Config
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
const PathSetting storeDir_{this, settings.nixStore,
|
|
||||||
"store",
|
|
||||||
R"(
|
|
||||||
Logical location of the Nix store, usually
|
|
||||||
`/nix/store`. Note that you can only copy store paths
|
|
||||||
between stores if they have the same `store` setting.
|
|
||||||
)"};
|
|
||||||
const Path storeDir = storeDir_;
|
|
||||||
|
|
||||||
const Setting<int> pathInfoCacheSize{this, 65536, "path-info-cache-size",
|
const Setting<int> pathInfoCacheSize{this, 65536, "path-info-cache-size",
|
||||||
"Size of the in-memory store path metadata cache."};
|
"Size of the in-memory store path metadata cache."};
|
||||||
|
|
||||||
|
@ -226,45 +220,6 @@ public:
|
||||||
|
|
||||||
virtual std::string getUri() = 0;
|
virtual std::string getUri() = 0;
|
||||||
|
|
||||||
StorePath parseStorePath(std::string_view path) const;
|
|
||||||
|
|
||||||
std::optional<StorePath> maybeParseStorePath(std::string_view path) const;
|
|
||||||
|
|
||||||
std::string printStorePath(const StorePath & path) const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deprecated
|
|
||||||
*
|
|
||||||
* \todo remove
|
|
||||||
*/
|
|
||||||
StorePathSet parseStorePathSet(const PathSet & paths) const;
|
|
||||||
|
|
||||||
PathSet printStorePathSet(const StorePathSet & path) const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Display a set of paths in human-readable form (i.e., between quotes
|
|
||||||
* and separated by commas).
|
|
||||||
*/
|
|
||||||
std::string showPaths(const StorePathSet & paths);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return true if ‘path’ is in the Nix store (but not the Nix
|
|
||||||
* store itself).
|
|
||||||
*/
|
|
||||||
bool isInStore(PathView path) const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return true if ‘path’ is a store path, i.e. a direct child of the
|
|
||||||
* Nix store.
|
|
||||||
*/
|
|
||||||
bool isStorePath(std::string_view path) const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Split a path like /nix/store/<hash>-<name>/<bla> into
|
|
||||||
* /nix/store/<hash>-<name> and /<bla>.
|
|
||||||
*/
|
|
||||||
std::pair<StorePath, Path> toStorePath(PathView path) const;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Follow symlinks until we end up with a path in the Nix store.
|
* Follow symlinks until we end up with a path in the Nix store.
|
||||||
*/
|
*/
|
||||||
|
@ -276,55 +231,6 @@ public:
|
||||||
*/
|
*/
|
||||||
StorePath followLinksToStorePath(std::string_view path) const;
|
StorePath followLinksToStorePath(std::string_view path) const;
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs a unique store path name.
|
|
||||||
*/
|
|
||||||
StorePath makeStorePath(std::string_view type,
|
|
||||||
std::string_view hash, std::string_view name) const;
|
|
||||||
StorePath makeStorePath(std::string_view type,
|
|
||||||
const Hash & hash, std::string_view name) const;
|
|
||||||
|
|
||||||
StorePath makeOutputPath(std::string_view id,
|
|
||||||
const Hash & hash, std::string_view name) const;
|
|
||||||
|
|
||||||
StorePath makeFixedOutputPath(std::string_view name, const FixedOutputInfo & info) const;
|
|
||||||
|
|
||||||
StorePath makeTextPath(std::string_view name, const TextInfo & info) const;
|
|
||||||
|
|
||||||
StorePath makeFixedOutputPathFromCA(std::string_view name, const ContentAddressWithReferences & ca) const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Read-only variant of addToStoreFromDump(). It returns the store
|
|
||||||
* path to which a NAR or flat file would be written.
|
|
||||||
*/
|
|
||||||
std::pair<StorePath, Hash> computeStorePathFromDump(
|
|
||||||
Source & dump,
|
|
||||||
std::string_view name,
|
|
||||||
FileIngestionMethod method = FileIngestionMethod::Recursive,
|
|
||||||
HashType hashAlgo = htSHA256,
|
|
||||||
const StorePathSet & references = {}) const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Preparatory part of addTextToStore().
|
|
||||||
*
|
|
||||||
* !!! Computation of the path should take the references given to
|
|
||||||
* addTextToStore() into account, otherwise we have a (relatively
|
|
||||||
* minor) security hole: a caller can register a source file with
|
|
||||||
* bogus references. If there are too many references, the path may
|
|
||||||
* not be garbage collected when it has to be (not really a problem,
|
|
||||||
* the caller could create a root anyway), or it may be garbage
|
|
||||||
* collected when it shouldn't be (more serious).
|
|
||||||
*
|
|
||||||
* Hashing the references would solve this (bogus references would
|
|
||||||
* simply yield a different store path, so other users wouldn't be
|
|
||||||
* affected), but it has some backwards compatibility issues (the
|
|
||||||
* hashing scheme changes), so I'm not doing that for now.
|
|
||||||
*/
|
|
||||||
StorePath computeStorePathForText(
|
|
||||||
std::string_view name,
|
|
||||||
std::string_view s,
|
|
||||||
const StorePathSet & references) const;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check whether a path is valid.
|
* Check whether a path is valid.
|
||||||
*/
|
*/
|
||||||
|
@ -888,7 +794,7 @@ void copyStorePath(
|
||||||
*/
|
*/
|
||||||
std::map<StorePath, StorePath> copyPaths(
|
std::map<StorePath, StorePath> copyPaths(
|
||||||
Store & srcStore, Store & dstStore,
|
Store & srcStore, Store & dstStore,
|
||||||
const RealisedPath::Set &,
|
const std::set<RealisedPath> &,
|
||||||
RepairFlag repair = NoRepair,
|
RepairFlag repair = NoRepair,
|
||||||
CheckSigsFlag checkSigs = CheckSigs,
|
CheckSigsFlag checkSigs = CheckSigs,
|
||||||
SubstituteFlag substitute = NoSubstitute);
|
SubstituteFlag substitute = NoSubstitute);
|
||||||
|
@ -905,7 +811,7 @@ std::map<StorePath, StorePath> copyPaths(
|
||||||
*/
|
*/
|
||||||
void copyClosure(
|
void copyClosure(
|
||||||
Store & srcStore, Store & dstStore,
|
Store & srcStore, Store & dstStore,
|
||||||
const RealisedPath::Set & paths,
|
const std::set<RealisedPath> & paths,
|
||||||
RepairFlag repair = NoRepair,
|
RepairFlag repair = NoRepair,
|
||||||
CheckSigsFlag checkSigs = CheckSigs,
|
CheckSigsFlag checkSigs = CheckSigs,
|
||||||
SubstituteFlag substitute = NoSubstitute);
|
SubstituteFlag substitute = NoSubstitute);
|
||||||
|
|
126
src/libstore/store-dir-config.hh
Normal file
126
src/libstore/store-dir-config.hh
Normal file
|
@ -0,0 +1,126 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "path.hh"
|
||||||
|
#include "hash.hh"
|
||||||
|
#include "content-address.hh"
|
||||||
|
#include "globals.hh"
|
||||||
|
#include "config.hh"
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
#include <string>
|
||||||
|
#include <variant>
|
||||||
|
|
||||||
|
|
||||||
|
namespace nix {
|
||||||
|
|
||||||
|
MakeError(BadStorePath, Error);
|
||||||
|
|
||||||
|
struct StoreDirConfig : public Config
|
||||||
|
{
|
||||||
|
using Config::Config;
|
||||||
|
|
||||||
|
StoreDirConfig() = delete;
|
||||||
|
|
||||||
|
virtual ~StoreDirConfig() = default;
|
||||||
|
|
||||||
|
const PathSetting storeDir_{this, settings.nixStore,
|
||||||
|
"store",
|
||||||
|
R"(
|
||||||
|
Logical location of the Nix store, usually
|
||||||
|
`/nix/store`. Note that you can only copy store paths
|
||||||
|
between stores if they have the same `store` setting.
|
||||||
|
)"};
|
||||||
|
const Path storeDir = storeDir_;
|
||||||
|
|
||||||
|
// pure methods
|
||||||
|
|
||||||
|
StorePath parseStorePath(std::string_view path) const;
|
||||||
|
|
||||||
|
std::optional<StorePath> maybeParseStorePath(std::string_view path) const;
|
||||||
|
|
||||||
|
std::string printStorePath(const StorePath & path) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deprecated
|
||||||
|
*
|
||||||
|
* \todo remove
|
||||||
|
*/
|
||||||
|
StorePathSet parseStorePathSet(const PathSet & paths) const;
|
||||||
|
|
||||||
|
PathSet printStorePathSet(const StorePathSet & path) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display a set of paths in human-readable form (i.e., between quotes
|
||||||
|
* and separated by commas).
|
||||||
|
*/
|
||||||
|
std::string showPaths(const StorePathSet & paths);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return true if ‘path’ is in the Nix store (but not the Nix
|
||||||
|
* store itself).
|
||||||
|
*/
|
||||||
|
bool isInStore(PathView path) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return true if ‘path’ is a store path, i.e. a direct child of the
|
||||||
|
* Nix store.
|
||||||
|
*/
|
||||||
|
bool isStorePath(std::string_view path) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Split a path like /nix/store/<hash>-<name>/<bla> into
|
||||||
|
* /nix/store/<hash>-<name> and /<bla>.
|
||||||
|
*/
|
||||||
|
std::pair<StorePath, Path> toStorePath(PathView path) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a unique store path name.
|
||||||
|
*/
|
||||||
|
StorePath makeStorePath(std::string_view type,
|
||||||
|
std::string_view hash, std::string_view name) const;
|
||||||
|
StorePath makeStorePath(std::string_view type,
|
||||||
|
const Hash & hash, std::string_view name) const;
|
||||||
|
|
||||||
|
StorePath makeOutputPath(std::string_view id,
|
||||||
|
const Hash & hash, std::string_view name) const;
|
||||||
|
|
||||||
|
StorePath makeFixedOutputPath(std::string_view name, const FixedOutputInfo & info) const;
|
||||||
|
|
||||||
|
StorePath makeTextPath(std::string_view name, const TextInfo & info) const;
|
||||||
|
|
||||||
|
StorePath makeFixedOutputPathFromCA(std::string_view name, const ContentAddressWithReferences & ca) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read-only variant of addToStoreFromDump(). It returns the store
|
||||||
|
* path to which a NAR or flat file would be written.
|
||||||
|
*/
|
||||||
|
std::pair<StorePath, Hash> computeStorePathFromDump(
|
||||||
|
Source & dump,
|
||||||
|
std::string_view name,
|
||||||
|
FileIngestionMethod method = FileIngestionMethod::Recursive,
|
||||||
|
HashType hashAlgo = htSHA256,
|
||||||
|
const StorePathSet & references = {}) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Preparatory part of addTextToStore().
|
||||||
|
*
|
||||||
|
* !!! Computation of the path should take the references given to
|
||||||
|
* addTextToStore() into account, otherwise we have a (relatively
|
||||||
|
* minor) security hole: a caller can register a source file with
|
||||||
|
* bogus references. If there are too many references, the path may
|
||||||
|
* not be garbage collected when it has to be (not really a problem,
|
||||||
|
* the caller could create a root anyway), or it may be garbage
|
||||||
|
* collected when it shouldn't be (more serious).
|
||||||
|
*
|
||||||
|
* Hashing the references would solve this (bogus references would
|
||||||
|
* simply yield a different store path, so other users wouldn't be
|
||||||
|
* affected), but it has some backwards compatibility issues (the
|
||||||
|
* hashing scheme changes), so I'm not doing that for now.
|
||||||
|
*/
|
||||||
|
StorePath computeStorePathForText(
|
||||||
|
std::string_view name,
|
||||||
|
std::string_view s,
|
||||||
|
const StorePathSet & references) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
|
@ -16,11 +16,11 @@ namespace nix {
|
||||||
/* protocol-agnostic templates */
|
/* protocol-agnostic templates */
|
||||||
|
|
||||||
#define WORKER_USE_LENGTH_PREFIX_SERIALISER(TEMPLATE, T) \
|
#define WORKER_USE_LENGTH_PREFIX_SERIALISER(TEMPLATE, T) \
|
||||||
TEMPLATE T WorkerProto::Serialise< T >::read(const Store & store, WorkerProto::ReadConn conn) \
|
TEMPLATE T WorkerProto::Serialise< T >::read(const StoreDirConfig & store, WorkerProto::ReadConn conn) \
|
||||||
{ \
|
{ \
|
||||||
return LengthPrefixedProtoHelper<WorkerProto, T >::read(store, conn); \
|
return LengthPrefixedProtoHelper<WorkerProto, T >::read(store, conn); \
|
||||||
} \
|
} \
|
||||||
TEMPLATE void WorkerProto::Serialise< T >::write(const Store & store, WorkerProto::WriteConn conn, const T & t) \
|
TEMPLATE void WorkerProto::Serialise< T >::write(const StoreDirConfig & store, WorkerProto::WriteConn conn, const T & t) \
|
||||||
{ \
|
{ \
|
||||||
LengthPrefixedProtoHelper<WorkerProto, T >::write(store, conn, t); \
|
LengthPrefixedProtoHelper<WorkerProto, T >::write(store, conn, t); \
|
||||||
}
|
}
|
||||||
|
@ -41,12 +41,12 @@ WORKER_USE_LENGTH_PREFIX_SERIALISER(
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct WorkerProto::Serialise
|
struct WorkerProto::Serialise
|
||||||
{
|
{
|
||||||
static T read(const Store & store, WorkerProto::ReadConn conn)
|
static T read(const StoreDirConfig & store, WorkerProto::ReadConn conn)
|
||||||
{
|
{
|
||||||
return CommonProto::Serialise<T>::read(store,
|
return CommonProto::Serialise<T>::read(store,
|
||||||
CommonProto::ReadConn { .from = conn.from });
|
CommonProto::ReadConn { .from = conn.from });
|
||||||
}
|
}
|
||||||
static void write(const Store & store, WorkerProto::WriteConn conn, const T & t)
|
static void write(const StoreDirConfig & store, WorkerProto::WriteConn conn, const T & t)
|
||||||
{
|
{
|
||||||
CommonProto::Serialise<T>::write(store,
|
CommonProto::Serialise<T>::write(store,
|
||||||
CommonProto::WriteConn { .to = conn.to },
|
CommonProto::WriteConn { .to = conn.to },
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace nix {
|
||||||
|
|
||||||
/* protocol-specific definitions */
|
/* protocol-specific definitions */
|
||||||
|
|
||||||
std::optional<TrustedFlag> WorkerProto::Serialise<std::optional<TrustedFlag>>::read(const Store & store, WorkerProto::ReadConn conn)
|
std::optional<TrustedFlag> WorkerProto::Serialise<std::optional<TrustedFlag>>::read(const StoreDirConfig & store, WorkerProto::ReadConn conn)
|
||||||
{
|
{
|
||||||
auto temp = readNum<uint8_t>(conn.from);
|
auto temp = readNum<uint8_t>(conn.from);
|
||||||
switch (temp) {
|
switch (temp) {
|
||||||
|
@ -28,7 +28,7 @@ std::optional<TrustedFlag> WorkerProto::Serialise<std::optional<TrustedFlag>>::r
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorkerProto::Serialise<std::optional<TrustedFlag>>::write(const Store & store, WorkerProto::WriteConn conn, const std::optional<TrustedFlag> & optTrusted)
|
void WorkerProto::Serialise<std::optional<TrustedFlag>>::write(const StoreDirConfig & store, WorkerProto::WriteConn conn, const std::optional<TrustedFlag> & optTrusted)
|
||||||
{
|
{
|
||||||
if (!optTrusted)
|
if (!optTrusted)
|
||||||
conn.to << uint8_t{0};
|
conn.to << uint8_t{0};
|
||||||
|
@ -47,7 +47,7 @@ void WorkerProto::Serialise<std::optional<TrustedFlag>>::write(const Store & sto
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DerivedPath WorkerProto::Serialise<DerivedPath>::read(const Store & store, WorkerProto::ReadConn conn)
|
DerivedPath WorkerProto::Serialise<DerivedPath>::read(const StoreDirConfig & store, WorkerProto::ReadConn conn)
|
||||||
{
|
{
|
||||||
auto s = readString(conn.from);
|
auto s = readString(conn.from);
|
||||||
if (GET_PROTOCOL_MINOR(conn.version) >= 30) {
|
if (GET_PROTOCOL_MINOR(conn.version) >= 30) {
|
||||||
|
@ -57,7 +57,7 @@ DerivedPath WorkerProto::Serialise<DerivedPath>::read(const Store & store, Worke
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorkerProto::Serialise<DerivedPath>::write(const Store & store, WorkerProto::WriteConn conn, const DerivedPath & req)
|
void WorkerProto::Serialise<DerivedPath>::write(const StoreDirConfig & store, WorkerProto::WriteConn conn, const DerivedPath & req)
|
||||||
{
|
{
|
||||||
if (GET_PROTOCOL_MINOR(conn.version) >= 30) {
|
if (GET_PROTOCOL_MINOR(conn.version) >= 30) {
|
||||||
conn.to << req.to_string_legacy(store);
|
conn.to << req.to_string_legacy(store);
|
||||||
|
@ -81,7 +81,7 @@ void WorkerProto::Serialise<DerivedPath>::write(const Store & store, WorkerProto
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
KeyedBuildResult WorkerProto::Serialise<KeyedBuildResult>::read(const Store & store, WorkerProto::ReadConn conn)
|
KeyedBuildResult WorkerProto::Serialise<KeyedBuildResult>::read(const StoreDirConfig & store, WorkerProto::ReadConn conn)
|
||||||
{
|
{
|
||||||
auto path = WorkerProto::Serialise<DerivedPath>::read(store, conn);
|
auto path = WorkerProto::Serialise<DerivedPath>::read(store, conn);
|
||||||
auto br = WorkerProto::Serialise<BuildResult>::read(store, conn);
|
auto br = WorkerProto::Serialise<BuildResult>::read(store, conn);
|
||||||
|
@ -91,14 +91,14 @@ KeyedBuildResult WorkerProto::Serialise<KeyedBuildResult>::read(const Store & st
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorkerProto::Serialise<KeyedBuildResult>::write(const Store & store, WorkerProto::WriteConn conn, const KeyedBuildResult & res)
|
void WorkerProto::Serialise<KeyedBuildResult>::write(const StoreDirConfig & store, WorkerProto::WriteConn conn, const KeyedBuildResult & res)
|
||||||
{
|
{
|
||||||
WorkerProto::write(store, conn, res.path);
|
WorkerProto::write(store, conn, res.path);
|
||||||
WorkerProto::write(store, conn, static_cast<const BuildResult &>(res));
|
WorkerProto::write(store, conn, static_cast<const BuildResult &>(res));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BuildResult WorkerProto::Serialise<BuildResult>::read(const Store & store, WorkerProto::ReadConn conn)
|
BuildResult WorkerProto::Serialise<BuildResult>::read(const StoreDirConfig & store, WorkerProto::ReadConn conn)
|
||||||
{
|
{
|
||||||
BuildResult res;
|
BuildResult res;
|
||||||
res.status = static_cast<BuildResult::Status>(readInt(conn.from));
|
res.status = static_cast<BuildResult::Status>(readInt(conn.from));
|
||||||
|
@ -120,7 +120,7 @@ BuildResult WorkerProto::Serialise<BuildResult>::read(const Store & store, Worke
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorkerProto::Serialise<BuildResult>::write(const Store & store, WorkerProto::WriteConn conn, const BuildResult & res)
|
void WorkerProto::Serialise<BuildResult>::write(const StoreDirConfig & store, WorkerProto::WriteConn conn, const BuildResult & res)
|
||||||
{
|
{
|
||||||
conn.to
|
conn.to
|
||||||
<< res.status
|
<< res.status
|
||||||
|
@ -141,7 +141,7 @@ void WorkerProto::Serialise<BuildResult>::write(const Store & store, WorkerProto
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ValidPathInfo WorkerProto::Serialise<ValidPathInfo>::read(const Store & store, ReadConn conn)
|
ValidPathInfo WorkerProto::Serialise<ValidPathInfo>::read(const StoreDirConfig & store, ReadConn conn)
|
||||||
{
|
{
|
||||||
auto path = WorkerProto::Serialise<StorePath>::read(store, conn);
|
auto path = WorkerProto::Serialise<StorePath>::read(store, conn);
|
||||||
return ValidPathInfo {
|
return ValidPathInfo {
|
||||||
|
@ -150,14 +150,14 @@ ValidPathInfo WorkerProto::Serialise<ValidPathInfo>::read(const Store & store, R
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorkerProto::Serialise<ValidPathInfo>::write(const Store & store, WriteConn conn, const ValidPathInfo & pathInfo)
|
void WorkerProto::Serialise<ValidPathInfo>::write(const StoreDirConfig & store, WriteConn conn, const ValidPathInfo & pathInfo)
|
||||||
{
|
{
|
||||||
WorkerProto::write(store, conn, pathInfo.path);
|
WorkerProto::write(store, conn, pathInfo.path);
|
||||||
WorkerProto::write(store, conn, static_cast<const UnkeyedValidPathInfo &>(pathInfo));
|
WorkerProto::write(store, conn, static_cast<const UnkeyedValidPathInfo &>(pathInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
UnkeyedValidPathInfo WorkerProto::Serialise<UnkeyedValidPathInfo>::read(const Store & store, ReadConn conn)
|
UnkeyedValidPathInfo WorkerProto::Serialise<UnkeyedValidPathInfo>::read(const StoreDirConfig & store, ReadConn conn)
|
||||||
{
|
{
|
||||||
auto deriver = readString(conn.from);
|
auto deriver = readString(conn.from);
|
||||||
auto narHash = Hash::parseAny(readString(conn.from), htSHA256);
|
auto narHash = Hash::parseAny(readString(conn.from), htSHA256);
|
||||||
|
@ -173,7 +173,7 @@ UnkeyedValidPathInfo WorkerProto::Serialise<UnkeyedValidPathInfo>::read(const St
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorkerProto::Serialise<UnkeyedValidPathInfo>::write(const Store & store, WriteConn conn, const UnkeyedValidPathInfo & pathInfo)
|
void WorkerProto::Serialise<UnkeyedValidPathInfo>::write(const StoreDirConfig & store, WriteConn conn, const UnkeyedValidPathInfo & pathInfo)
|
||||||
{
|
{
|
||||||
conn.to
|
conn.to
|
||||||
<< (pathInfo.deriver ? store.printStorePath(*pathInfo.deriver) : "")
|
<< (pathInfo.deriver ? store.printStorePath(*pathInfo.deriver) : "")
|
||||||
|
|
|
@ -24,7 +24,7 @@ namespace nix {
|
||||||
#define STDERR_RESULT 0x52534c54
|
#define STDERR_RESULT 0x52534c54
|
||||||
|
|
||||||
|
|
||||||
class Store;
|
struct StoreDirConfig;
|
||||||
struct Source;
|
struct Source;
|
||||||
|
|
||||||
// items being serialised
|
// items being serialised
|
||||||
|
@ -100,8 +100,8 @@ struct WorkerProto
|
||||||
// This makes for a quicker debug cycle, as desired.
|
// This makes for a quicker debug cycle, as desired.
|
||||||
#if 0
|
#if 0
|
||||||
{
|
{
|
||||||
static T read(const Store & store, ReadConn conn);
|
static T read(const StoreDirConfig & store, ReadConn conn);
|
||||||
static void write(const Store & store, WriteConn conn, const T & t);
|
static void write(const StoreDirConfig & store, WriteConn conn, const T & t);
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ struct WorkerProto
|
||||||
* infer the type instead of having to write it down explicitly.
|
* infer the type instead of having to write it down explicitly.
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static void write(const Store & store, WriteConn conn, const T & t)
|
static void write(const StoreDirConfig & store, WriteConn conn, const T & t)
|
||||||
{
|
{
|
||||||
WorkerProto::Serialise<T>::write(store, conn, t);
|
WorkerProto::Serialise<T>::write(store, conn, t);
|
||||||
}
|
}
|
||||||
|
@ -198,8 +198,8 @@ inline std::ostream & operator << (std::ostream & s, WorkerProto::Op op)
|
||||||
#define DECLARE_WORKER_SERIALISER(T) \
|
#define DECLARE_WORKER_SERIALISER(T) \
|
||||||
struct WorkerProto::Serialise< T > \
|
struct WorkerProto::Serialise< T > \
|
||||||
{ \
|
{ \
|
||||||
static T read(const Store & store, WorkerProto::ReadConn conn); \
|
static T read(const StoreDirConfig & store, WorkerProto::ReadConn conn); \
|
||||||
static void write(const Store & store, WorkerProto::WriteConn conn, const T & t); \
|
static void write(const StoreDirConfig & store, WorkerProto::WriteConn conn, const T & t); \
|
||||||
};
|
};
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include "store-api.hh"
|
#include "store-api.hh"
|
||||||
#include "local-fs-store.hh"
|
#include "local-fs-store.hh"
|
||||||
#include "globals.hh"
|
#include "globals.hh"
|
||||||
|
#include "realisation.hh"
|
||||||
#include "derivations.hh"
|
#include "derivations.hh"
|
||||||
#include "shared.hh"
|
#include "shared.hh"
|
||||||
#include "path-with-outputs.hh"
|
#include "path-with-outputs.hh"
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "shared.hh"
|
#include "shared.hh"
|
||||||
|
#include "realisation.hh"
|
||||||
#include "store-api.hh"
|
#include "store-api.hh"
|
||||||
#include "legacy.hh"
|
#include "legacy.hh"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue