Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/libflake/flake-primops.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <vector>

#include "nix/flake/flake-primops.hh"
#include "nix/store/store-api.hh"
#include "nix/expr/eval.hh"
#include "nix/flake/flake.hh"
#include "nix/flake/flakeref.hh"
Expand Down Expand Up @@ -66,6 +67,25 @@ PrimOp getFlake(const Settings & settings)
flakeRefS,
state.positions[pos]);

/* Backward compatibility hack: If this is a `path` flake and it's a virtual path that had
* `unsafeDiscardStringContext` applied to it, then treat it like the `nPath` case, i.e. call lockFlake() on
* the virtual path directly. This is necessary because the `path` fetcher doesn't see virtual paths. */
if (flakeRef.input.getType() == "path") {
if (auto sourcePath = flakeRef.input.getSourcePath();
sourcePath && state.store->isInStore(sourcePath->string())) {
auto [storePath, subPath] = state.store->toStorePath(sourcePath->string());
for (auto & c : context) {
if (auto p = std::get_if<NixStringContextElem::Path>(&c.raw); p && p->storePath == storePath) {
auto path = state.storePath(storePath) / CanonPath(subPath);
if (!flakeRef.subdir.empty())
path = path / flakeRef.subdir;
callFlake(state, lockFlake(settings, state, path, lockFlags), v);
return;
}
}
}
}

callFlake(state, lockFlake(settings, state, flakeRef, lockFlags), v);
}
};
Expand Down
Loading