aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2019-11-08 15:22:54 +0100
committerEelco Dolstra <edolstra@gmail.com>2019-11-08 15:22:54 +0100
commit2c1e05ae9389742dac637a6f051f718397eff2db (patch)
tree35fe97f937e11baf97871ed093ca819c3986f557 /src
parent0bc0d35b6ba252a1f3ec5d92acecdd041328d811 (diff)
parent0d6774468cf109c9cb6502cb81f1219c6e68ee37 (diff)
Merge remote-tracking branch 'origin/master' into flakes
Diffstat (limited to 'src')
-rw-r--r--src/libutil/args.cc13
-rw-r--r--src/libutil/args.hh4
-rw-r--r--src/nix/command.cc14
-rw-r--r--src/nix/command.hh5
4 files changed, 19 insertions, 17 deletions
diff --git a/src/libutil/args.cc b/src/libutil/args.cc
index ad7a268fc..ba15ea571 100644
--- a/src/libutil/args.cc
+++ b/src/libutil/args.cc
@@ -178,19 +178,6 @@ Strings argvToStrings(int argc, char * * argv)
return args;
}
-Strings editorFor(Pos pos)
-{
- auto editor = getEnv("EDITOR", "cat");
- auto args = tokenizeString<Strings>(editor);
- if (pos.line > 0 && (
- editor.find("emacs") != std::string::npos ||
- editor.find("nano") != std::string::npos ||
- editor.find("vim") != std::string::npos))
- args.push_back(fmt("+%d", pos.line));
- args.push_back(pos.file);
- return args;
-}
-
std::string renderLabels(const Strings & labels)
{
std::string res;
diff --git a/src/libutil/args.hh b/src/libutil/args.hh
index 59d427ee6..b960a55a8 100644
--- a/src/libutil/args.hh
+++ b/src/libutil/args.hh
@@ -5,7 +5,6 @@
#include <memory>
#include "util.hh"
-#include "nixexpr.hh"
namespace nix {
@@ -242,9 +241,6 @@ public:
Strings argvToStrings(int argc, char * * argv);
-/* Helper function to generate args that invoke $EDITOR on filename:lineno */
-Strings editorFor(Pos pos);
-
/* Helper function for rendering argument labels. */
std::string renderLabels(const Strings & labels);
diff --git a/src/nix/command.cc b/src/nix/command.cc
index 1cb4cc92a..111b5a10f 100644
--- a/src/nix/command.cc
+++ b/src/nix/command.cc
@@ -1,6 +1,7 @@
#include "command.hh"
#include "store-api.hh"
#include "derivations.hh"
+#include "nixexpr.hh"
#include "profiles.hh"
namespace nix {
@@ -82,6 +83,19 @@ void StorePathCommand::run(ref<Store> store)
run(store, *storePaths.begin());
}
+Strings editorFor(const Pos & pos)
+{
+ auto editor = getEnv("EDITOR", "cat");
+ auto args = tokenizeString<Strings>(editor);
+ if (pos.line > 0 && (
+ editor.find("emacs") != std::string::npos ||
+ editor.find("nano") != std::string::npos ||
+ editor.find("vim") != std::string::npos))
+ args.push_back(fmt("+%d", pos.line));
+ args.push_back(pos.file);
+ return args;
+}
+
MixProfile::MixProfile()
{
mkFlag()
diff --git a/src/nix/command.hh b/src/nix/command.hh
index 13f3a0dc9..82dbb55d0 100644
--- a/src/nix/command.hh
+++ b/src/nix/command.hh
@@ -11,6 +11,7 @@ namespace nix {
extern std::string programPath;
class EvalState;
+struct Pos;
class Store;
namespace flake {
@@ -175,6 +176,10 @@ PathSet toDerivations(ref<Store> store,
std::vector<std::shared_ptr<Installable>> installables,
bool useDeriver = false);
+/* Helper function to generate args that invoke $EDITOR on
+ filename:lineno. */
+Strings editorFor(const Pos & pos);
+
struct MixProfile : virtual Args, virtual StoreCommand
{
std::optional<Path> profile;