From 9d0ef2b589eb5ed0a9da873886afad7671502781 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 30 Jan 2024 11:39:17 +0100 Subject: [PATCH] Set ATUIN_ variables for development in devshell I accidentially broke my atuin database by executing `atuin` from the PR I was working on without setting these variables and had to manually roll back my local database. That shouldn't happen, so we set the database and record store path in the devshell to something that does not overwrite our normal databases. We also warn if these files already exist, because when entering the devshell, a user might want to start from a clean slate here. Signed-off-by: Matthias Beyer --- flake.nix | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/flake.nix b/flake.nix index ee5dcdd30fa..678337540cc 100644 --- a/flake.nix +++ b/flake.nix @@ -30,6 +30,20 @@ rustfmt ]; RUST_SRC_PATH = "${pkgs.rustPlatform.rustLibSrc}"; + + shellHook = '' + echo >&2 "Setting development database path" + export ATUIN_DB_PATH="/tmp/atuin_dev.db" + export ATUIN_RECORD_STORE_PATH="/tmp/atuin_records.db" + + if [ -e "''${ATUIN_DB_PATH}" ]; then + echo >&2 "''${ATUIN_DB_PATH} already exists, you might want to double-check that" + fi + + if [ -e "''${ATUIN_RECORD_STORE_PATH}" ]; then + echo >&2 "''${ATUIN_RECORD_STORE_PATH} already exists, you might want to double-check that" + fi + ''; }); }) // {