From a0c0c8994cc3e7047c51804f08c95308424ea344 Mon Sep 17 00:00:00 2001 From: Kiana Sheibani Date: Mon, 22 Jul 2024 13:34:08 -0400 Subject: [PATCH] feat(file-templates): add Nix flake file template --- config.org | 11 +++++++++++ snippets/nix-mode/__flake.nix | 17 +++++++++++++++++ snippets/snippet-mode/__ | 2 +- 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 snippets/nix-mode/__flake.nix diff --git a/config.org b/config.org index 0c21ed7..f8d1263 100644 --- a/config.org +++ b/config.org @@ -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. +**** 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 #+call: confpkg("Pkg: ispell") diff --git a/snippets/nix-mode/__flake.nix b/snippets/nix-mode/__flake.nix new file mode 100644 index 0000000..527afd4 --- /dev/null +++ b/snippets/nix-mode/__flake.nix @@ -0,0 +1,17 @@ +# -*- mode: snippet -*- +# contributor: Kiana Sheibani +# 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 +} diff --git a/snippets/snippet-mode/__ b/snippets/snippet-mode/__ index b987244..1b64388 100644 --- a/snippets/snippet-mode/__ +++ b/snippets/snippet-mode/__ @@ -1,5 +1,5 @@ # -*- mode: snippet -*- -# contributor: Kiana Sheibani +# contributor: Kiana Sheibani # key: __ # name: Snippet template # --