mirror of
https://github.com/NixOS/nix.git
synced 2025-11-13 22:12:43 +01:00
Merge remote-tracking branch 'origin/detsys-main' into flakehub-inputs
This commit is contained in:
commit
6898f04a32
3 changed files with 77 additions and 1 deletions
|
|
@ -5,6 +5,7 @@
|
|||
#include "nix/util/json-utils.hh"
|
||||
#include "nix/fetchers/store-path-accessor.hh"
|
||||
#include "nix/fetchers/fetch-settings.hh"
|
||||
#include "nix/util/forwarding-source-accessor.hh"
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
|
|
@ -293,6 +294,21 @@ std::pair<ref<SourceAccessor>, Input> Input::getAccessor(ref<Store> store) const
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper class that ensures that paths in substituted source trees
|
||||
* are rendered as `«input»/path` rather than
|
||||
* `«input»/nix/store/<hash>-source/path`.
|
||||
*/
|
||||
struct SubstitutedSourceAccessor : ForwardingSourceAccessor
|
||||
{
|
||||
using ForwardingSourceAccessor::ForwardingSourceAccessor;
|
||||
|
||||
std::string showPath(const CanonPath & path) override
|
||||
{
|
||||
return displayPrefix + path.abs() + displaySuffix;
|
||||
}
|
||||
};
|
||||
|
||||
std::pair<ref<SourceAccessor>, Input> Input::getAccessorUnchecked(ref<Store> store) const
|
||||
{
|
||||
// FIXME: cache the accessor
|
||||
|
|
@ -320,10 +336,12 @@ std::pair<ref<SourceAccessor>, Input> Input::getAccessorUnchecked(ref<Store> sto
|
|||
debug("using substituted/cached input '%s' in '%s'",
|
||||
to_string(), store->printStorePath(storePath));
|
||||
|
||||
auto accessor = makeStorePathAccessor(store, storePath);
|
||||
auto accessor = make_ref<SubstitutedSourceAccessor>(makeStorePathAccessor(store, storePath));
|
||||
|
||||
accessor->fingerprint = getFingerprint(store);
|
||||
|
||||
// FIXME: ideally we would use the `showPath()` of the
|
||||
// "real" accessor for this fetcher type.
|
||||
accessor->setPathDisplay("«" + to_string() + "»");
|
||||
|
||||
return {accessor, *this};
|
||||
|
|
|
|||
57
src/libutil/include/nix/util/forwarding-source-accessor.hh
Normal file
57
src/libutil/include/nix/util/forwarding-source-accessor.hh
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
#pragma once
|
||||
|
||||
#include "source-accessor.hh"
|
||||
|
||||
namespace nix {
|
||||
|
||||
/**
|
||||
* A source accessor that just forwards every operation to another
|
||||
* accessor. This is not useful in itself but can be used as a
|
||||
* superclass for accessors that do change some operations.
|
||||
*/
|
||||
struct ForwardingSourceAccessor : SourceAccessor
|
||||
{
|
||||
ref<SourceAccessor> next;
|
||||
|
||||
ForwardingSourceAccessor(ref<SourceAccessor> next)
|
||||
: next(next)
|
||||
{
|
||||
}
|
||||
|
||||
std::string readFile(const CanonPath & path) override
|
||||
{
|
||||
return next->readFile(path);
|
||||
}
|
||||
|
||||
void readFile(const CanonPath & path, Sink & sink, std::function<void(uint64_t)> sizeCallback) override
|
||||
{
|
||||
next->readFile(path, sink, sizeCallback);
|
||||
}
|
||||
|
||||
std::optional<Stat> maybeLstat(const CanonPath & path) override
|
||||
{
|
||||
return next->maybeLstat(path);
|
||||
}
|
||||
|
||||
DirEntries readDirectory(const CanonPath & path) override
|
||||
{
|
||||
return next->readDirectory(path);
|
||||
}
|
||||
|
||||
std::string readLink(const CanonPath & path) override
|
||||
{
|
||||
return next->readLink(path);
|
||||
}
|
||||
|
||||
std::string showPath(const CanonPath & path) override
|
||||
{
|
||||
return next->showPath(path);
|
||||
}
|
||||
|
||||
std::optional<std::filesystem::path> getPhysicalPath(const CanonPath & path) override
|
||||
{
|
||||
return next->getPhysicalPath(path);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
@ -34,6 +34,7 @@ headers = files(
|
|||
'file-system.hh',
|
||||
'finally.hh',
|
||||
'fmt.hh',
|
||||
'forwarding-source-accessor.hh',
|
||||
'fs-sink.hh',
|
||||
'git.hh',
|
||||
'hash.hh',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue