diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2020-02-07 14:22:01 +0100 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2020-03-24 14:06:47 +0100 |
commit | 231a8aa2c2196a3ba6d6bd3dc9d6c50e23e20a8d (patch) | |
tree | 9fb2341478d781e3f3f3b8a88c22cf619622466a /src/nix/edit.cc | |
parent | c1ca4f0accdb96295b27dadacd20b3db745e1d2d (diff) |
nix edit: Support non-derivation attributes
E.g.
$ nix edit .#nixosConfigurations.bla
now works.
(cherry picked from commit d2032edb2f86e955a8a7724a27c0c3225f386500)
Diffstat (limited to 'src/nix/edit.cc')
-rw-r--r-- | src/nix/edit.cc | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/nix/edit.cc b/src/nix/edit.cc index ca410cd1f..1683eada0 100644 --- a/src/nix/edit.cc +++ b/src/nix/edit.cc @@ -29,9 +29,15 @@ struct CmdEdit : InstallableCommand { auto state = getEvalState(); - auto v = installable->toValue(*state); + auto [v, pos] = installable->toValue(*state); - Pos pos = findDerivationFilename(*state, *v, installable->what()); + try { + pos = findDerivationFilename(*state, *v, installable->what()); + } catch (NoPositionInfo &) { + } + + if (pos == noPos) + throw Error("cannot find position information for '%s", installable->what()); stopProgressBar(); |