feat: generalize Nix module file template
This commit is contained in:
parent
7a5a588385
commit
17a9aed526
1 changed files with 8 additions and 2 deletions
10
config.org
10
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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue