From 786216dfcb12fa850a8d79b18a44f0c03fe23df1 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Fri, 10 Jun 2022 11:41:37 -0700 Subject: [PATCH] top-level: Ignore Emacs lock files when looking for overlays While an Emacs user edits a file foo.nix, Emacs creates a lock file .#foo.nix as a broken symlink to USER@HOSTNAME.PID:TIMESTAMP. https://www.gnu.org/software/emacs/manual/html_node/emacs/Interlocking.html If the file is in the overlays directory, this breaks all nixpkgs imports with this error, until the user saves the file: error: getting status of '/home/user/.config/nixpkgs/overlays/user@hostname.683628:1654370645': No such file or directory Fix this by ignoring filenames beginning with .# in overlay directories. Signed-off-by: Anders Kaseorg --- pkgs/top-level/impure.nix | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkgs/top-level/impure.nix b/pkgs/top-level/impure.nix index 242596d28c6b..4d847e280f4b 100644 --- a/pkgs/top-level/impure.nix +++ b/pkgs/top-level/impure.nix @@ -47,7 +47,12 @@ in # it's a directory, so the set of overlays from the directory, ordered lexicographically let content = builtins.readDir path; in map (n: import (path + ("/" + n))) - (builtins.filter (n: builtins.match ".*\\.nix" n != null || builtins.pathExists (path + ("/" + n + "/default.nix"))) + (builtins.filter + (n: + (builtins.match ".*\\.nix" n != null && + # ignore Emacs lock files (.#foo.nix) + builtins.match "\\.#.*" n == null) || + builtins.pathExists (path + ("/" + n + "/default.nix"))) (builtins.attrNames content)) else # it's a file, so the result is the contents of the file itself