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 <andersk@mit.edu>

+6 -1
+6 -1
pkgs/top-level/impure.nix
··· 47 47 # it's a directory, so the set of overlays from the directory, ordered lexicographically 48 48 let content = builtins.readDir path; in 49 49 map (n: import (path + ("/" + n))) 50 - (builtins.filter (n: builtins.match ".*\\.nix" n != null || builtins.pathExists (path + ("/" + n + "/default.nix"))) 50 + (builtins.filter 51 + (n: 52 + (builtins.match ".*\\.nix" n != null && 53 + # ignore Emacs lock files (.#foo.nix) 54 + builtins.match "\\.#.*" n == null) || 55 + builtins.pathExists (path + ("/" + n + "/default.nix"))) 51 56 (builtins.attrNames content)) 52 57 else 53 58 # it's a file, so the result is the contents of the file itself