Merge pull request #10814 from Mic92/fix-nix-edit

Fix nix edit
This commit is contained in:
Robert Hensing 2024-05-31 13:30:24 +02:00 committed by GitHub
commit 802b4e403b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 23 additions and 0 deletions

View file

@ -2,6 +2,12 @@
namespace nix {
std::optional<std::filesystem::path> FilteringSourceAccessor::getPhysicalPath(const CanonPath & path)
{
checkAccess(path);
return next->getPhysicalPath(prefix / path);
}
std::string FilteringSourceAccessor::readFile(const CanonPath & path)
{
checkAccess(path);

View file

@ -30,6 +30,8 @@ struct FilteringSourceAccessor : SourceAccessor
displayPrefix.clear();
}
std::optional<std::filesystem::path> getPhysicalPath(const CanonPath & path) override;
std::string readFile(const CanonPath & path) override;
bool pathExists(const CanonPath & path) override;

13
tests/functional/flakes/edit.sh Executable file
View file

@ -0,0 +1,13 @@
#!/usr/bin/env bash
source ./common.sh
requireGit
flake1Dir=$TEST_ROOT/flake1
createGitRepo "$flake1Dir"
createSimpleGitFlake "$flake1Dir"
export EDITOR=cat
nix edit "$flake1Dir#" | grepQuiet simple.builder.sh

View file

@ -2,6 +2,7 @@ nix_tests = \
test-infra.sh \
flakes/flakes.sh \
flakes/develop.sh \
flakes/edit.sh \
flakes/run.sh \
flakes/mercurial.sh \
flakes/circular.sh \

View file

@ -5,4 +5,5 @@ mkDerivation {
builder = ./simple.builder.sh;
PATH = "";
goodPath = path;
meta.position = "${__curPos.file}:${toString __curPos.line}";
}