3
0
Fork 0
forked from mirrors/nixpkgs

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>
This commit is contained in:
Anders Kaseorg 2022-06-10 11:41:37 -07:00
parent e0169d7a9d
commit 786216dfcb

View file

@ -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