diff --git a/nix/home/opdavies/default.nix b/nix/home/opdavies/default.nix
index da0a59f..ed478be 100644
--- a/nix/home/opdavies/default.nix
+++ b/nix/home/opdavies/default.nix
@@ -77,6 +77,7 @@ in
     XDG_DATA_HOME = "${config.xdg.dataHome}";
     XDG_DOCUMENTS_DIR = "$HOME/Documents";
     XDG_REPOS_DIR = "$HOME/Code";
+    XDG_STATE_HOME = config.xdg.stateHome;
   };
 
   xdg.configFile = {
diff --git a/nvim/lua/opdavies/options.lua b/nvim/lua/opdavies/options.lua
index 3bdd40d..5b94dff 100644
--- a/nvim/lua/opdavies/options.lua
+++ b/nvim/lua/opdavies/options.lua
@@ -35,7 +35,7 @@ local settings = {
   tabstop = 2,
   termguicolors = true,
   textwidth = 0,
-  undodir = os.getenv "HOME" .. "/.vim/undodir",
+  undodir = os.getenv "XDG_STATE_HOME" .. "/nvim/undodir",
   undofile = true,
   updatetime = 1000,
   wrap = false,