From 17a9aed52694833fdd6550f04128b5557df390aa Mon Sep 17 00:00:00 2001 From: Kiana Sheibani Date: Wed, 22 Oct 2025 13:32:46 -0400 Subject: [PATCH] feat: generalize Nix module file template --- config.org | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/config.org b/config.org index 95fc012..8f8000c 100644 --- a/config.org +++ b/config.org @@ -2306,12 +2306,18 @@ Now that we have our new-and-improved template registry system, we can add new f **** Nix -The default Nix file template is for a NixOS module. This is nice when you're writing a module, but most Nix files aren't modules. We'll restrict the default template to only trigger for files inside ~/etc/nixos~, and for there to be no template in other cases. We'll also add a template for flakes. +The default Nix file template is for a NixOS module. This is nice when you're writing a module, but most Nix files aren't modules. We'll restrict the default template to only trigger for files inside NixOS configurations, and for there to be no template in other cases. We'll also add a template for flakes. #+begin_src emacs-lisp +(defvar ~/nixos-config-projects '() + "A list of project directories which contain NixOS configurations.") +(setq ~/nixos-config-projects + (mapcar #'expand-file-name + '("/etc/nixos/" "~/nix/nixos-config/" "~/nix/aether/"))) + (set-file-templates! '(nix-mode :remove t) - '("/etc/nixos/.*\\.nix$" :mode nix-mode) + '(nix-mode :when (lambda (_) (member (doom-project-root) ~/nixos-config-projects))) '("/flake\\.nix$" :trigger "__flake.nix" :mode nix-mode)) #+end_src