after upgrading to NixOS 25.11, Samba returns outdated directory listings not showing new files. my client is an updated Windows 10 ESU. search for bugs in both nixpkgs and samba, need to fix. seems like it's cached for like a minute or so?
Thought for 2m 36s
What you’re seeing lines up very well with SMB3 Directory Leases being enabled after your upgrade.
NixOS 25.11 ships Samba 4.22.x (e.g. 4.22.5 in stable 25.11). GitHub
Samba 4.22 introduced “SMB3 Directory Leases” and enables them by default on non-clustered installs. Samba+1
Directory leases let the Windows client cache directory listings. Samba+1
If files are created/renamed outside of SMB (locally on the server by a service, rsync, download tool, etc.), Samba may not revoke the lease promptly, so Explorer keeps showing an old listing until the lease times out / gets invalidated. This exact “minutes later it appears” behavior has been reported, and disabling directory leases fixes it. Samba Mailing Lists+1
(And Samba’s own interoperability docs explicitly note that inotify change notifications are not used to break leases; local changes can therefore be a problem unless you change caching/locking behavior.) SambaWiki
In smb.conf, set:
smb3 directory leases = noSamba+1
Use whichever style you already use:
Option A (module settings):
nix
Copy code
services.samba = { enable = true; settings = { global = { "smb3 directory leases" = "no"; }; }; };
Option B (extraConfig):
nix
Copy code
services.samba.extraConfig = '' smb3 directory leases = no '';
Then sudo nixos-rebuild switch.
After that, on Windows, close/reopen Explorer windows (or disconnect/reconnect the share) so it drops the cached lease state.
The man page notes directory leases only apply when smb2 leases=yes, oplocks=yes, and kernel oplocks=no. Samba
So another way to avoid directory leases is setting kernel oplocks = yes, which also helps Samba notice some local modifications via kernel leases — but it comes with behavior/perf trade-offs and disables some advanced SMB2 caching features. SambaWiki+1