From bcde5456cc3295061a0726881c3e441444dd6680 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Sat, 21 Mar 2020 11:07:16 -0400 Subject: Flip dependency so store-api.hh includes derivations.hh I think it makes more sense to define the data model (derivations), before the operations (store api). --- src/libstore/store-api.hh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/libstore/store-api.hh') diff --git a/src/libstore/store-api.hh b/src/libstore/store-api.hh index 0fa59be6a..396709633 100644 --- a/src/libstore/store-api.hh +++ b/src/libstore/store-api.hh @@ -8,6 +8,7 @@ #include "sync.hh" #include "globals.hh" #include "config.hh" +#include "derivations.hh" #include #include @@ -30,15 +31,12 @@ MakeError(SubstituteGone, Error); MakeError(SubstituterDisabled, Error); -struct BasicDerivation; -struct Derivation; class FSAccessor; class NarInfoDiskCache; class Store; class JSONPlaceholder; -enum RepairFlag : bool { NoRepair = false, Repair = true }; enum CheckSigsFlag : bool { NoCheckSigs = false, CheckSigs = true }; enum SubstituteFlag : bool { NoSubstitute = false, Substitute = true }; enum AllowInvalidFlag : bool { DisallowInvalid = false, AllowInvalid = true }; -- cgit v1.2.3 From 0e9438b6d381a87946ddda8d4bdd06707f9b0a48 Mon Sep 17 00:00:00 2001 From: Carlo Nucera Date: Mon, 1 Jun 2020 17:32:27 -0400 Subject: Create new file-hash files --- src/libstore/store-api.hh | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'src/libstore/store-api.hh') diff --git a/src/libstore/store-api.hh b/src/libstore/store-api.hh index 598798570..d89e10c94 100644 --- a/src/libstore/store-api.hh +++ b/src/libstore/store-api.hh @@ -2,6 +2,7 @@ #include "path.hh" #include "hash.hh" +#include "file-hash.hh" #include "serialise.hh" #include "crypto.hh" #include "lru-cache.hh" @@ -846,15 +847,6 @@ std::optional decodeValidPathInfo( std::istream & str, bool hashGiven = false); -/* Compute the prefix to the hash algorithm which indicates how the files were - ingested. */ -std::string makeFileIngestionPrefix(const FileIngestionMethod m); - -/* Compute the content-addressability assertion (ValidPathInfo::ca) - for paths created by makeFixedOutputPath() / addToStore(). */ -std::string makeFixedOutputCA(FileIngestionMethod method, const Hash & hash); - - /* Split URI into protocol+hierarchy part and its parameter set. */ std::pair splitUriAndParams(const std::string & uri); -- cgit v1.2.3 From da39092a39bbcca80144041b5efc8428cc3b2e4a Mon Sep 17 00:00:00 2001 From: Carlo Nucera Date: Mon, 1 Jun 2020 18:53:31 -0400 Subject: WIP --- src/libstore/store-api.hh | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'src/libstore/store-api.hh') diff --git a/src/libstore/store-api.hh b/src/libstore/store-api.hh index d89e10c94..1f1c1e0eb 100644 --- a/src/libstore/store-api.hh +++ b/src/libstore/store-api.hh @@ -19,6 +19,7 @@ #include #include #include +#include namespace nix { @@ -110,6 +111,19 @@ struct SubstitutablePathInfo typedef std::map SubstitutablePathInfos; +template struct overloaded : Ts... { using Ts::operator()...; }; +template overloaded(Ts...) -> overloaded; + +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 { @@ -139,21 +153,11 @@ struct ValidPathInfo that a particular output path was produced by a derivation; the path then implies the contents.) - Ideally, the content-addressability assertion would just be a - Boolean, and the store path would be computed from - the name component, ‘narHash’ and ‘references’. However, - 1) we've accumulated several types of content-addressed paths - over the years; and 2) fixed-output derivations support - multiple hash algorithms and serialisation methods (flat file - vs NAR). Thus, ‘ca’ has one of the following forms: - - * ‘text:sha256:’: For paths - computed by makeTextPath() / addTextToStore(). - - * ‘fixed:::’: For paths computed by - makeFixedOutputPath() / addToStore(). + Ideally, the content-addressability assertion would just be a Boolean, + and the store path would be computed from the name component, ‘narHash’ + and ‘references’. However, we support many types of content addresses. */ - std::string ca; + std::optional ca; bool operator == (const ValidPathInfo & i) const { -- cgit v1.2.3 From 754c910953901ced4fbd27a8b86d36d57cb72996 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Mon, 1 Jun 2020 19:26:40 -0400 Subject: WIP more progress --- src/libstore/store-api.hh | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'src/libstore/store-api.hh') diff --git a/src/libstore/store-api.hh b/src/libstore/store-api.hh index 1f1c1e0eb..faf549fe1 100644 --- a/src/libstore/store-api.hh +++ b/src/libstore/store-api.hh @@ -111,20 +111,6 @@ struct SubstitutablePathInfo typedef std::map SubstitutablePathInfos; -template struct overloaded : Ts... { using Ts::operator()...; }; -template overloaded(Ts...) -> overloaded; - -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; -- cgit v1.2.3 From fd2eb41e6433e72516ae149949b8b0050305293d Mon Sep 17 00:00:00 2001 From: Carlo Nucera Date: Tue, 2 Jun 2020 15:44:58 -0400 Subject: Move file-hash to content-address --- src/libstore/store-api.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/libstore/store-api.hh') diff --git a/src/libstore/store-api.hh b/src/libstore/store-api.hh index 7836c04dc..441e3efc5 100644 --- a/src/libstore/store-api.hh +++ b/src/libstore/store-api.hh @@ -2,7 +2,7 @@ #include "path.hh" #include "hash.hh" -#include "file-hash.hh" +#include "content-address.hh" #include "serialise.hh" #include "crypto.hh" #include "lru-cache.hh" -- cgit v1.2.3