mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-10 08:16:15 +02:00
WIP more progress
This commit is contained in:
parent
da39092a39
commit
754c910953
6 changed files with 28 additions and 25 deletions
|
@ -24,4 +24,22 @@ std::string makeFixedOutputCA(FileIngestionMethod method, const Hash & hash)
|
|||
+ hash.to_string();
|
||||
}
|
||||
|
||||
template<class... Ts> struct overloaded : Ts... { using Ts::operator()...; };
|
||||
template<class... Ts> overloaded(Ts...) -> overloaded<Ts...>;
|
||||
|
||||
std::string renderContentAddress(ContentAddress ca) {
|
||||
return std::visit(overloaded {
|
||||
[](TextHash th) {
|
||||
return "text:" + th.hash.to_string();
|
||||
},
|
||||
[](FileSystemHash fsh) {
|
||||
return makeFixedOutputCA(fsh.method, fsh.hash);
|
||||
}
|
||||
}, ca);
|
||||
}
|
||||
|
||||
std::string renderContentAddress(std::optionalContent<Address> ca) {
|
||||
return ca ? renderContentAddress(*ca) else "";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -10,6 +10,10 @@ enum struct FileIngestionMethod : uint8_t {
|
|||
Recursive = true
|
||||
};
|
||||
|
||||
struct TextHash {
|
||||
Hash hash;
|
||||
};
|
||||
|
||||
/// Pair of a hash, and how the file system was ingested
|
||||
struct FileSystemHash {
|
||||
FileIngestionMethod method;
|
||||
|
@ -36,7 +40,7 @@ struct FileSystemHash {
|
|||
makeFixedOutputPath() / addToStore().
|
||||
*/
|
||||
typedef std::variant<
|
||||
Hash, // for paths computed by makeTextPath() / addTextToStore
|
||||
TextHash, // for paths computed by makeTextPath() / addTextToStore
|
||||
FileSystemHash // for path computed by makeFixedOutputPath
|
||||
> ContentAddress;
|
||||
|
||||
|
@ -48,4 +52,8 @@ std::string makeFileIngestionPrefix(const FileIngestionMethod m);
|
|||
for paths created by makeFixedOutputPath() / addToStore(). */
|
||||
std::string makeFixedOutputCA(FileIngestionMethod method, const Hash & hash);
|
||||
|
||||
std::string renderContentAddress(ContentAddress ca);
|
||||
|
||||
std::string renderContentAddress(std::optional<ContentAddress> ca);
|
||||
|
||||
}
|
||||
|
|
|
@ -88,15 +88,6 @@ const size_t storePathHashLen = 32; // i.e. 160 bits
|
|||
/* Extension of derivations in the Nix store. */
|
||||
const std::string drvExtension = ".drv";
|
||||
|
||||
std::string to_string(FileIngestionMethod m) {
|
||||
switch(m) {
|
||||
case FileIngestionMethod::Flat:
|
||||
return "false";
|
||||
case FileIngestionMethod::Recursive:
|
||||
return "true";
|
||||
}
|
||||
}
|
||||
|
||||
struct StorePathWithOutputs
|
||||
{
|
||||
StorePath path;
|
||||
|
|
|
@ -111,20 +111,6 @@ struct SubstitutablePathInfo
|
|||
|
||||
typedef std::map<StorePath, SubstitutablePathInfo> SubstitutablePathInfos;
|
||||
|
||||
template<class... Ts> struct overloaded : Ts... { using Ts::operator()...; };
|
||||
template<class... Ts> overloaded(Ts...) -> overloaded<Ts...>;
|
||||
|
||||
std::string renderContentAddress(ContentAddress ca) {
|
||||
return std::visit(overloaded {
|
||||
[](Hash hash) {
|
||||
return "text:" + hash.to_string();
|
||||
},
|
||||
[](FileSystemHash fsh) {
|
||||
return makeFixedOutputCA(fsh.method, fsh.hash);
|
||||
}
|
||||
}, ca);
|
||||
}
|
||||
|
||||
struct ValidPathInfo
|
||||
{
|
||||
StorePath path;
|
||||
|
|
Binary file not shown.
|
@ -115,7 +115,7 @@ struct CmdPathInfo : StorePathsCommand, MixJSON
|
|||
std::cout << '\t';
|
||||
Strings ss;
|
||||
if (info->ultimate) ss.push_back("ultimate");
|
||||
if (info->ca != "") ss.push_back("ca:" + info->ca);
|
||||
if (info->ca != "") ss.push_back("ca:" + renderContentAddress(*info->ca));
|
||||
for (auto & sig : info->sigs) ss.push_back(sig);
|
||||
std::cout << concatStringsSep(" ", ss);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue