|
5 | 5 | #include "nix/util/json-utils.hh" |
6 | 6 | #include "nix/fetchers/store-path-accessor.hh" |
7 | 7 | #include "nix/fetchers/fetch-settings.hh" |
| 8 | +#include "nix/util/forwarding-source-accessor.hh" |
8 | 9 |
|
9 | 10 | #include <nlohmann/json.hpp> |
10 | 11 |
|
@@ -293,6 +294,21 @@ std::pair<ref<SourceAccessor>, Input> Input::getAccessor(ref<Store> store) const |
293 | 294 | } |
294 | 295 | } |
295 | 296 |
|
| 297 | +/** |
| 298 | + * Helper class that ensures that paths in substituted source trees |
| 299 | + * are rendered as `«input»/path` rather than |
| 300 | + * `«input»/nix/store/<hash>-source/path`. |
| 301 | + */ |
| 302 | +struct SubstitutedSourceAccessor : ForwardingSourceAccessor |
| 303 | +{ |
| 304 | + using ForwardingSourceAccessor::ForwardingSourceAccessor; |
| 305 | + |
| 306 | + std::string showPath(const CanonPath & path) override |
| 307 | + { |
| 308 | + return displayPrefix + path.abs() + displaySuffix; |
| 309 | + } |
| 310 | +}; |
| 311 | + |
296 | 312 | std::pair<ref<SourceAccessor>, Input> Input::getAccessorUnchecked(ref<Store> store) const |
297 | 313 | { |
298 | 314 | // FIXME: cache the accessor |
@@ -320,10 +336,12 @@ std::pair<ref<SourceAccessor>, Input> Input::getAccessorUnchecked(ref<Store> sto |
320 | 336 | debug("using substituted/cached input '%s' in '%s'", |
321 | 337 | to_string(), store->printStorePath(storePath)); |
322 | 338 |
|
323 | | - auto accessor = makeStorePathAccessor(store, storePath); |
| 339 | + auto accessor = make_ref<SubstitutedSourceAccessor>(makeStorePathAccessor(store, storePath)); |
324 | 340 |
|
325 | 341 | accessor->fingerprint = getFingerprint(store); |
326 | 342 |
|
| 343 | + // FIXME: ideally we would use the `showPath()` of the |
| 344 | + // "real" accessor for this fetcher type. |
327 | 345 | accessor->setPathDisplay("«" + to_string() + "»"); |
328 | 346 |
|
329 | 347 | return {accessor, *this}; |
|
0 commit comments