aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/downstream-placeholder.cc
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2023-05-11 18:01:41 -0400
committerJohn Ericson <John.Ericson@Obsidian.Systems>2023-05-17 17:41:16 -0400
commitb9e5ce4a27f4a8bbee1a2eeb6fddbf569cbfdd7a (patch)
tree1e417565c4987a5e6ba3970ad22e069a088f735b /src/libstore/downstream-placeholder.cc
parente7c1113a37e6a8fd0dc2dde0d070dbef276a0481 (diff)
Upgrade `downstreamPlaceholder` to a type with methods
This gets us ready for dynamic derivation dependencies (part of RFC 92).
Diffstat (limited to 'src/libstore/downstream-placeholder.cc')
-rw-r--r--src/libstore/downstream-placeholder.cc39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/libstore/downstream-placeholder.cc b/src/libstore/downstream-placeholder.cc
new file mode 100644
index 000000000..1752738f2
--- /dev/null
+++ b/src/libstore/downstream-placeholder.cc
@@ -0,0 +1,39 @@
+#include "downstream-placeholder.hh"
+#include "derivations.hh"
+
+namespace nix {
+
+std::string DownstreamPlaceholder::render() const
+{
+ return "/" + hash.to_string(Base32, false);
+}
+
+
+DownstreamPlaceholder DownstreamPlaceholder::unknownCaOutput(
+ const StorePath & drvPath,
+ std::string_view outputName)
+{
+ auto drvNameWithExtension = drvPath.name();
+ auto drvName = drvNameWithExtension.substr(0, drvNameWithExtension.size() - 4);
+ auto clearText = "nix-upstream-output:" + std::string { drvPath.hashPart() } + ":" + outputPathName(drvName, outputName);
+ return DownstreamPlaceholder {
+ hashString(htSHA256, clearText)
+ };
+}
+
+DownstreamPlaceholder DownstreamPlaceholder::unknownDerivation(
+ const DownstreamPlaceholder & placeholder,
+ std::string_view outputName,
+ const ExperimentalFeatureSettings & xpSettings)
+{
+ xpSettings.require(Xp::DynamicDerivations);
+ auto compressed = compressHash(placeholder.hash, 20);
+ auto clearText = "nix-computed-output:"
+ + compressed.to_string(Base32, false)
+ + ":" + std::string { outputName };
+ return DownstreamPlaceholder {
+ hashString(htSHA256, clearText)
+ };
+}
+
+}