diff --git a/lix/libexpr/eval.cc b/lix/libexpr/eval.cc index 03a1c8cb8..352a01c35 100644 --- a/lix/libexpr/eval.cc +++ b/lix/libexpr/eval.cc @@ -14,7 +14,6 @@ #include "lix/libutil/types.hh" #include "lix/libstore/store-api.hh" #include "lix/libstore/derivations.hh" -#include "lix/libstore/downstream-placeholder.hh" #include "lix/libexpr/gc-alloc.hh" #include "lix/libstore/filetransfer.hh" #include "lix/libexpr/function-trace.hh" diff --git a/lix/libexpr/eval.hh b/lix/libexpr/eval.hh index 16081a79f..0c8185dfe 100644 --- a/lix/libexpr/eval.hh +++ b/lix/libexpr/eval.hh @@ -804,8 +804,7 @@ public: /** * Coerce to `SingleDerivedPath`. * - * Must be a string which is either a literal store path or a - * "placeholder (see `DownstreamPlaceholder`). + * Must be a string which is either a literal store path. * * Even more importantly, the string context must be exactly one * element, which is either a `NixStringContextElem::Opaque` or diff --git a/lix/libexpr/primops.cc b/lix/libexpr/primops.cc index e0c4dcef8..a36c845cf 100644 --- a/lix/libexpr/primops.cc +++ b/lix/libexpr/primops.cc @@ -1,6 +1,5 @@ #include "lix/libutil/archive.hh" #include "lix/libstore/derivations.hh" -#include "lix/libstore/downstream-placeholder.hh" #include "lix/libexpr/eval.hh" #include "lix/libexpr/eval-settings.hh" #include "lix/libexpr/extra-primops.hh" diff --git a/lix/libstore/derivations.cc b/lix/libstore/derivations.cc index 8a2740b90..af94e5f6c 100644 --- a/lix/libstore/derivations.cc +++ b/lix/libstore/derivations.cc @@ -1,5 +1,4 @@ #include "lix/libstore/derivations.hh" -#include "lix/libstore/downstream-placeholder.hh" #include "lix/libstore/store-api.hh" #include "lix/libstore/globals.hh" #include "lix/libutil/json.hh" diff --git a/lix/libstore/downstream-placeholder.cc b/lix/libstore/downstream-placeholder.cc deleted file mode 100644 index d113128ed..000000000 --- a/lix/libstore/downstream-placeholder.cc +++ /dev/null @@ -1,33 +0,0 @@ -#include "lix/libstore/downstream-placeholder.hh" -#include "lix/libstore/derivations.hh" - -namespace nix { - -std::string DownstreamPlaceholder::render() const -{ - return "/" + hash.to_string(Base::Base32, false); -} - - -DownstreamPlaceholder DownstreamPlaceholder::unknownCaOutput( - const StorePath & drvPath, - OutputNameView outputName, - const ExperimentalFeatureSettings & xpSettings) -{ - xpSettings.require(Xp::CaDerivations); - 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(HashType::SHA256, clearText) - }; -} - -DownstreamPlaceholder DownstreamPlaceholder::fromSingleDerivedPathBuilt( - const SingleDerivedPath::Built & b, - const ExperimentalFeatureSettings & xpSettings) -{ - return DownstreamPlaceholder::unknownCaOutput(b.drvPath.path, b.output, xpSettings); -} - -} diff --git a/lix/libstore/downstream-placeholder.hh b/lix/libstore/downstream-placeholder.hh deleted file mode 100644 index 8b6ee7a44..000000000 --- a/lix/libstore/downstream-placeholder.hh +++ /dev/null @@ -1,77 +0,0 @@ -#pragma once -///@file - -#include "lix/libutil/hash.hh" -#include "lix/libstore/path.hh" -#include "lix/libstore/derived-path.hh" - -namespace nix { - -/** - * Downstream Placeholders are opaque and almost certainly unique values - * used to allow derivations to refer to store objects which are yet to - * be built and for we do not yet have store paths for. - * - * They correspond to `DerivedPaths` that are not `DerivedPath::Opaque`, - * except for the cases involving input addressing or fixed outputs - * where we do know a store path for the derivation output in advance. - * - * Unlike `DerivationPath`, however, `DownstreamPlaceholder` is - * purposefully opaque and obfuscated. This is so they are hard to - * create by accident, and so substituting them (once we know what the - * path to store object is) is unlikely to capture other stuff it - * shouldn't. - * - * We use them with `Derivation`: the `render()` method is called to - * render an opaque string which can be used in the derivation, and the - * resolving logic can substitute those strings for store paths when - * resolving `Derivation.inputDrvs` to `BasicDerivation.inputSrcs`. - */ -class DownstreamPlaceholder -{ - /** - * `DownstreamPlaceholder` is just a newtype of `Hash`. - * This its only field. - */ - Hash hash; - - /** - * Newtype constructor - */ - DownstreamPlaceholder(Hash hash) : hash(hash) { } - -public: - /** - * This creates an opaque and almost certainly unique string - * deterministically from the placeholder. - */ - std::string render() const; - - /** - * Create a placeholder for an unknown output of a content-addressed - * derivation. - * - * The derivation itself is known (we have a store path for it), but - * the output doesn't yet have a known store path. - * - * @param xpSettings Stop-gap to avoid globals during unit tests. - */ - static DownstreamPlaceholder unknownCaOutput( - const StorePath & drvPath, - OutputNameView outputName, - const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings); - - /** - * Convenience constructor that handles both cases (unknown - * content-addressed output and unknown derivation), delegating as - * needed to `unknownCaOutput`. - * - * Recursively builds up a placeholder from a - * `SingleDerivedPath::Built.drvPath` chain. - */ - static DownstreamPlaceholder fromSingleDerivedPathBuilt( - const SingleDerivedPath::Built & built, - const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings); -}; - -} diff --git a/lix/libstore/meson.build b/lix/libstore/meson.build index 1dd83c477..729c5157b 100644 --- a/lix/libstore/meson.build +++ b/lix/libstore/meson.build @@ -156,7 +156,6 @@ libstore_sources = files( 'daemon.cc', 'derivations.cc', 'derived-path.cc', - 'downstream-placeholder.cc', 'dummy-store.cc', 'export-import.cc', 'filetransfer.cc', @@ -223,7 +222,6 @@ libstore_headers = files( 'daemon.hh', 'derivations.hh', 'derived-path.hh', - 'downstream-placeholder.hh', 'dummy-store.hh', 'filetransfer.hh', 'fs-accessor.hh', diff --git a/lix/nix/app.cc b/lix/nix/app.cc index 1aaf4997f..44b0a4583 100644 --- a/lix/nix/app.cc +++ b/lix/nix/app.cc @@ -7,7 +7,6 @@ #include "lix/libstore/names.hh" #include "lix/libcmd/command.hh" #include "lix/libstore/derivations.hh" -#include "lix/libstore/downstream-placeholder.hh" namespace nix { diff --git a/tests/unit/libstore/downstream-placeholder.cc b/tests/unit/libstore/downstream-placeholder.cc deleted file mode 100644 index 069e259f5..000000000 --- a/tests/unit/libstore/downstream-placeholder.cc +++ /dev/null @@ -1,23 +0,0 @@ -#include - -#include "lix/libstore/downstream-placeholder.hh" - -namespace nix { - -TEST(DownstreamPlaceholder, unknownCaOutput) { - /** - * We set these in tests rather than the regular globals so we don't have - * to worry about race conditions if the tests run concurrently. - */ - ExperimentalFeatureSettings mockXpSettings; - mockXpSettings.experimentalFeatures.override(ExperimentalFeatures{} | Xp::CaDerivations); - - ASSERT_EQ( - DownstreamPlaceholder::unknownCaOutput( - StorePath { "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo.drv" }, - "out", - mockXpSettings).render(), - "/0c6rn30q4frawknapgwq386zq358m8r6msvywcvc89n6m5p2dgbz"); -} - -} diff --git a/tests/unit/meson.build b/tests/unit/meson.build index 16d3cfd5c..3e24375df 100644 --- a/tests/unit/meson.build +++ b/tests/unit/meson.build @@ -136,7 +136,6 @@ libstore_tests_sources = files( 'libstore/common-protocol.cc', 'libstore/derivation.cc', 'libstore/derived-path.cc', - 'libstore/downstream-placeholder.cc', 'libstore/filetransfer.cc', 'libstore/machines.cc', 'libstore/nar-info-disk-cache.cc',