fix(ipython): keep in-session history in memory only

Assisted-by: DeepSeek Harness (deepseek-flash)
This commit is contained in:
Ryan Yin committed 2026-11-05 12:38:55 +08:00
1 parent d7c493f5cd
commit 9f29b48bf6
3 files changed
+12 -9

No files matched your search

+3 -1
View File
@@ -2,7 +2,9 @@
[`default.nix`](./default.nix) manages `~/.ipython/profile_default` with two pieces: [`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 - `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 also pre-imports a small set of common standard-library names such as `Path`, `Counter`, and
`datetime`. `datetime`.
+5 -4
View File
@@ -1,13 +1,14 @@
{ ... }: { ... }:
{ {
# Interactive IPython sessions routinely handle credentials and other # Interactive IPython sessions routinely handle credentials and other
# sensitive values, so keep the SQLite history disabled rather than relying # sensitive values, so keep the SQLite history in memory instead of on disk:
# on the profile directory's lifetime. Home Manager recreates these files # arrow-key recall and %history still work within a session, but no history
# from the Nix store on every activation. # file is written. Home Manager recreates these files from the Nix store on
# every activation.
home.file = { home.file = {
".ipython/profile_default/ipython_config.py".text = '' ".ipython/profile_default/ipython_config.py".text = ''
c = get_config() c = get_config()
c.HistoryManager.enabled = False c.HistoryManager.hist_file = ":memory:"
''; '';
".ipython/profile_default/startup/10-data-helpers.py".source = ./data-helpers.py; ".ipython/profile_default/startup/10-data-helpers.py".source = ./data-helpers.py;
}; };
+4 -4
View File
@@ -222,10 +222,10 @@ in
".config/Joplin" # joplin-desktop ".config/Joplin" # joplin-desktop
".local/share/jupyter" ".local/share/jupyter"
# Deliberately not persisted: ~/.ipython contains history.sqlite, and # Deliberately not persisted: IPython keeps its history database in
# interactive sessions may contain credentials or other sensitive # memory (HistoryManager.hist_file = ":memory:") and the profile config
# values. Home Manager recreates the profile config and startup helpers # and startup helpers are recreated from the Nix store on every
# from the Nix store on every activation. # activation, so this directory holds no state worth preserving.
# ====================================== # ======================================
# Cloud Native # Cloud Native