Skip to content

Commit

Permalink
Merge pull request #10814 from Mic92/fix-nix-edit
Browse files Browse the repository at this point in the history
Fix nix edit
  • Loading branch information
roberth authored May 31, 2024
2 parents 84e1163 + 69c1598 commit 802b4e4
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/libfetchers/filtering-source-accessor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions src/libfetchers/filtering-source-accessor.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
13 changes: 13 additions & 0 deletions tests/functional/flakes/edit.sh
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions tests/functional/local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
1 change: 1 addition & 0 deletions tests/functional/simple.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ mkDerivation {
builder = ./simple.builder.sh;
PATH = "";
goodPath = path;
meta.position = "${__curPos.file}:${toString __curPos.line}";
}

0 comments on commit 802b4e4

Please sign in to comment.