From 9f29b48bf6a632569465875c56e10aadf4e9a859 Mon Sep 17 00:00:00 2001 From: Ryan Yin Date: Thu, 5 Nov 2026 12:38:55 +0800 Subject: [PATCH] fix(ipython): keep in-session history in memory only Assisted-by: DeepSeek Harness (deepseek-flash) --- home/base/tui/editors/ipython/README.md | 4 +++- home/base/tui/editors/ipython/default.nix | 9 +++++---- hosts/idols-ai/preservation.nix | 8 ++++---- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/home/base/tui/editors/ipython/README.md b/home/base/tui/editors/ipython/README.md index 89cf1930..d873e948 100644 --- a/home/base/tui/editors/ipython/README.md +++ b/home/base/tui/editors/ipython/README.md @@ -2,7 +2,9 @@ [`default.nix`](./default.nix) manages `~/.ipython/profile_default` with two pieces: -- `ipython_config.py` disables SQLite history because interactive sessions may contain secrets. +- `ipython_config.py` keeps SQLite history in memory (`HistoryManager.hist_file = ":memory:"`), so + arrow keys and `%history` recall the current session while nothing is written to disk, because + interactive sessions may contain secrets. - `startup/10-data-helpers.py` loads JSON, YAML, TOML, and CSV helpers at every IPython start. It also pre-imports a small set of common standard-library names such as `Path`, `Counter`, and `datetime`. diff --git a/home/base/tui/editors/ipython/default.nix b/home/base/tui/editors/ipython/default.nix index 366413b8..6b839444 100644 --- a/home/base/tui/editors/ipython/default.nix +++ b/home/base/tui/editors/ipython/default.nix @@ -1,13 +1,14 @@ { ... }: { # Interactive IPython sessions routinely handle credentials and other - # sensitive values, so keep the SQLite history disabled rather than relying - # on the profile directory's lifetime. Home Manager recreates these files - # from the Nix store on every activation. + # sensitive values, so keep the SQLite history in memory instead of on disk: + # arrow-key recall and %history still work within a session, but no history + # file is written. Home Manager recreates these files from the Nix store on + # every activation. home.file = { ".ipython/profile_default/ipython_config.py".text = '' c = get_config() - c.HistoryManager.enabled = False + c.HistoryManager.hist_file = ":memory:" ''; ".ipython/profile_default/startup/10-data-helpers.py".source = ./data-helpers.py; }; diff --git a/hosts/idols-ai/preservation.nix b/hosts/idols-ai/preservation.nix index 045ad79b..40c69d64 100644 --- a/hosts/idols-ai/preservation.nix +++ b/hosts/idols-ai/preservation.nix @@ -222,10 +222,10 @@ in ".config/Joplin" # joplin-desktop ".local/share/jupyter" - # Deliberately not persisted: ~/.ipython contains history.sqlite, and - # interactive sessions may contain credentials or other sensitive - # values. Home Manager recreates the profile config and startup helpers - # from the Nix store on every activation. + # Deliberately not persisted: IPython keeps its history database in + # memory (HistoryManager.hist_file = ":memory:") and the profile config + # and startup helpers are recreated from the Nix store on every + # activation, so this directory holds no state worth preserving. # ====================================== # Cloud Native