about summary refs log tree commit diff
path: root/src/nix/repl.cc
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2017-04-25T16·56+0200
committerEelco Dolstra <edolstra@gmail.com>2017-04-25T16·56+0200
commit5bd8795e1fa9255836fbbeab0a22f5038d92d53c (patch)
tree8df5a5f1c13b080f38e6a4e27f6ac64073133273 /src/nix/repl.cc
parent921a2aeb0537f34bc2b41e98e67a1c829321ee81 (diff)
nix repl: Use $XDG_DATA_HOME for the readline history
Diffstat (limited to 'src/nix/repl.cc')
-rw-r--r--src/nix/repl.cc7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/nix/repl.cc b/src/nix/repl.cc
index 54e48e405b89..78d973ba8320 100644
--- a/src/nix/repl.cc
+++ b/src/nix/repl.cc
@@ -29,9 +29,6 @@ using namespace std;
 #define ESC_CYA "\033[36m"
 #define ESC_END "\033[0m"
 
-string programId = "nix-repl";
-const string historyFile = string(getenv("HOME")) + "/.nix-repl-history";
-
 struct NixRepl
 {
     string curDir;
@@ -45,6 +42,8 @@ struct NixRepl
     int displ;
     StringSet varNames;
 
+    const Path historyFile;
+
     StringSet completions;
     StringSet::iterator curCompletion;
 
@@ -115,6 +114,7 @@ string removeWhitespace(string s)
 NixRepl::NixRepl(const Strings & searchPath, nix::ref<Store> store)
     : state(searchPath, store)
     , staticEnv(false, &state.staticBaseEnv)
+    , historyFile(getDataDir() + "/nix/repl-history")
 {
     curDir = absPath(".");
 }
@@ -140,6 +140,7 @@ void NixRepl::mainLoop(const Strings & files)
     // Allow nix-repl specific settings in .inputrc
     rl_readline_name = "nix-repl";
     using_history();
+    createDirs(dirOf(historyFile));
     read_history(historyFile.c_str());
 
     string input;