feat(file-templates): add Nix flake file template

This commit is contained in:
Kiana Sheibani 2024-07-22 13:34:08 -04:00
parent 4fb75bf17b
commit a0c0c8994c
Signed by: toki
GPG key ID: 6CB106C25E86A9F7
3 changed files with 29 additions and 1 deletions

View file

@ -2181,6 +2181,17 @@ This system works well for the most part, but there's a serious issue with its U
Now that we have our new-and-improved template registry system, we can add new file templates as we please. Now that we have our new-and-improved template registry system, we can add new file templates as we please.
**** 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.
#+begin_src emacs-lisp
(set-file-templates!
'(nix-mode :remove t)
'("/etc/nixos/.*\\.nix$" :mode nix-mode)
'("/flake\\.nix$" :trigger "__flake.nix" :mode nix-mode))
#+end_src
** Spell Checking ** Spell Checking
#+call: confpkg("Pkg: ispell") #+call: confpkg("Pkg: ispell")

View file

@ -0,0 +1,17 @@
# -*- mode: snippet -*-
# contributor: Kiana Sheibani <kiana.a.sheibani@gmail.com>
# key: __flake.nix
# name: nix flake template
# --
{
description = "${1:Flake description}";
inputs = {
${2:nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
}${3:flake-utils.url = "github:numtide/flake-utils";
}$4
};
outputs = { self$5, ... }:
$0
}

View file

@ -1,5 +1,5 @@
# -*- mode: snippet -*- # -*- mode: snippet -*-
# contributor: Kiana Sheibani # contributor: Kiana Sheibani <kiana.a.sheibani@gmail.com>
# key: __ # key: __
# name: Snippet template # name: Snippet template
# -- # --