aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkshay <[email protected]>2021-10-06 03:33:01 +0100
committerAkshay <[email protected]>2021-10-06 03:33:01 +0100
commit5acd4c77a0ad5499fbd558e8f93f461f84ab26d1 (patch)
tree4faa6cf3b9a9d569bdd295b8db4f8e98efd90892
parent89b779f6bfbd476d5302e740a4ad3263a15a8974 (diff)
add missing syntax highlighting
-rw-r--r--docs/index.xml242
-rw-r--r--docs/posts/novice_nix:_flake_templates/index.html242
-rw-r--r--posts/novice_nix:_flake_templates.md24
3 files changed, 254 insertions, 254 deletions
diff --git a/docs/index.xml b/docs/index.xml
index d45ba57..3246f7a 100644
--- a/docs/index.xml
+++ b/docs/index.xml
@@ -15,53 +15,53 @@
15<title>Novice Nix: Flake Templates</title> 15<title>Novice Nix: Flake Templates</title>
16<description>&lt;p&gt;Flakes are very handy to setup entirely pure, project-specific dependencies (not just dependencies, but build steps, shell environments and more) in a declarative way. Writing Flake expressions can get repetitive though, oftentimes, you’d much rather start off with a skeleton. Luckily, &lt;code&gt;nix&lt;/code&gt; already supports templates!&lt;/p&gt; 16<description>&lt;p&gt;Flakes are very handy to setup entirely pure, project-specific dependencies (not just dependencies, but build steps, shell environments and more) in a declarative way. Writing Flake expressions can get repetitive though, oftentimes, you’d much rather start off with a skeleton. Luckily, &lt;code&gt;nix&lt;/code&gt; already supports templates!&lt;/p&gt;
17&lt;p&gt;You might already be familiar with &lt;code&gt;nix flake init&lt;/code&gt;, that drops a “default” flake expression into your current working directory. If you head over to the manpage:&lt;/p&gt; 17&lt;p&gt;You might already be familiar with &lt;code&gt;nix flake init&lt;/code&gt;, that drops a “default” flake expression into your current working directory. If you head over to the manpage:&lt;/p&gt;
18&lt;pre&gt;&lt;code&gt;nix flake init --help&lt;/code&gt;&lt;/pre&gt; 18&lt;div class="sourceCode" id="cb1"&gt;&lt;pre class="sourceCode bash"&gt;&lt;code class="sourceCode bash"&gt;&lt;span id="cb1-1"&gt;&lt;a href="#cb1-1" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;nix&lt;/span&gt; flake init &lt;span class="at"&gt;--help&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
19&lt;p&gt;You will read that &lt;code&gt;nix flake init&lt;/code&gt; creates a flake using the “default template”. Additionally, you can create a flake from a specific template by passing the &lt;code&gt;-t&lt;/code&gt; flag. Where does this default originate from?&lt;/p&gt; 19&lt;p&gt;You will read that &lt;code&gt;nix flake init&lt;/code&gt; creates a flake using the “default template”. Additionally, you can create a flake from a specific template by passing the &lt;code&gt;-t&lt;/code&gt; flag. Where does this default originate from?&lt;/p&gt;
20&lt;h2 id="flake-registries"&gt;Flake Registries&lt;/h2&gt; 20&lt;h2 id="flake-registries"&gt;Flake Registries&lt;/h2&gt;
21&lt;p&gt;Quick detour into registries! Registries are a way to alias popular flakes using identifiers:&lt;/p&gt; 21&lt;p&gt;Quick detour into registries! Registries are a way to alias popular flakes using identifiers:&lt;/p&gt;
22&lt;pre&gt;&lt;code&gt;# list a few predefined registries 22&lt;div class="sourceCode" id="cb2"&gt;&lt;pre class="sourceCode bash"&gt;&lt;code class="sourceCode bash"&gt;&lt;span id="cb2-1"&gt;&lt;a href="#cb2-1" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="co"&gt;# list a few predefined registries&lt;/span&gt;&lt;/span&gt;
23$ nix registry list 23&lt;span id="cb2-2"&gt;&lt;a href="#cb2-2" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;$&lt;/span&gt; nix registry list&lt;/span&gt;
24. . . 24&lt;span id="cb2-3"&gt;&lt;a href="#cb2-3" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="bu"&gt;.&lt;/span&gt; . . &lt;/span&gt;
25global flake:nixpkgs github:NixOS/nixpkgs 25&lt;span id="cb2-4"&gt;&lt;a href="#cb2-4" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;global&lt;/span&gt; flake:nixpkgs github:NixOS/nixpkgs&lt;/span&gt;
26global flake:patchelf github:NixOS/patchelf 26&lt;span id="cb2-5"&gt;&lt;a href="#cb2-5" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;global&lt;/span&gt; flake:patchelf github:NixOS/patchelf&lt;/span&gt;
27global flake:nix-serve github:edolstra/nix-serve 27&lt;span id="cb2-6"&gt;&lt;a href="#cb2-6" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;global&lt;/span&gt; flake:nix-serve github:edolstra/nix-serve&lt;/span&gt;
28global flake:templates github:NixOS/templates 28&lt;span id="cb2-7"&gt;&lt;a href="#cb2-7" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;global&lt;/span&gt; flake:templates github:NixOS/templates&lt;/span&gt;
29global flake:nickel github:tweag/nickel 29&lt;span id="cb2-8"&gt;&lt;a href="#cb2-8" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;global&lt;/span&gt; flake:nickel github:tweag/nickel&lt;/span&gt;
30. . . 30&lt;span id="cb2-9"&gt;&lt;a href="#cb2-9" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="bu"&gt;.&lt;/span&gt; . .&lt;/span&gt;
31 31&lt;span id="cb2-10"&gt;&lt;a href="#cb2-10" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;/span&gt;
32# you can do 32&lt;span id="cb2-11"&gt;&lt;a href="#cb2-11" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="co"&gt;# you can do &lt;/span&gt;&lt;/span&gt;
33$ nix flake show nickel 33&lt;span id="cb2-12"&gt;&lt;a href="#cb2-12" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;$&lt;/span&gt; nix flake show nickel&lt;/span&gt;
34 34&lt;span id="cb2-13"&gt;&lt;a href="#cb2-13" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;/span&gt;
35# instead of 35&lt;span id="cb2-14"&gt;&lt;a href="#cb2-14" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="co"&gt;# instead of &lt;/span&gt;&lt;/span&gt;
36$ nix flake show github:tweag/nickel 36&lt;span id="cb2-15"&gt;&lt;a href="#cb2-15" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;$&lt;/span&gt; nix flake show github:tweag/nickel&lt;/span&gt;
37 37&lt;span id="cb2-16"&gt;&lt;a href="#cb2-16" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;/span&gt;
38# which is short for 38&lt;span id="cb2-17"&gt;&lt;a href="#cb2-17" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="co"&gt;# which is short for&lt;/span&gt;&lt;/span&gt;
39$ nix flake show git+https://github.com/tweag/nickel&lt;/code&gt;&lt;/pre&gt; 39&lt;span id="cb2-18"&gt;&lt;a href="#cb2-18" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;$&lt;/span&gt; nix flake show git+https://github.com/tweag/nickel&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
40&lt;p&gt;You might notice a registry called &lt;code&gt;templates&lt;/code&gt; aliased to &lt;code&gt;github:NixOS/templates&lt;/code&gt;. Take a peek with &lt;code&gt;nix flake show&lt;/code&gt;:&lt;/p&gt; 40&lt;p&gt;You might notice a registry called &lt;code&gt;templates&lt;/code&gt; aliased to &lt;code&gt;github:NixOS/templates&lt;/code&gt;. Take a peek with &lt;code&gt;nix flake show&lt;/code&gt;:&lt;/p&gt;
41&lt;pre&gt;&lt;code&gt;$ nix flake show templates 41&lt;div class="sourceCode" id="cb3"&gt;&lt;pre class="sourceCode bash"&gt;&lt;code class="sourceCode bash"&gt;&lt;span id="cb3-1"&gt;&lt;a href="#cb3-1" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;$&lt;/span&gt; nix flake show templates&lt;/span&gt;
42github:NixOS/templates/79f48a7b822f35c068c5e235da2e9fbd154cecee 42&lt;span id="cb3-2"&gt;&lt;a href="#cb3-2" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;github:NixOS/templates/79f48a7b822f35c068c5e235da2e9fbd154cecee&lt;/span&gt;&lt;/span&gt;
43├───defaultTemplate: template: A very basic flake 43&lt;span id="cb3-3"&gt;&lt;a href="#cb3-3" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;├───defaultTemplate:&lt;/span&gt; template: A very basic flake&lt;/span&gt;
44└───templates 44&lt;span id="cb3-4"&gt;&lt;a href="#cb3-4" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;└───templates&lt;/span&gt;&lt;/span&gt;
45 ├───bash-hello: template: An over-engineered Hello World in bash 45&lt;span id="cb3-5"&gt;&lt;a href="#cb3-5" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="ex"&gt;├───bash-hello:&lt;/span&gt; template: An over-engineered Hello World in bash&lt;/span&gt;
46 ├───c-hello: template: An over-engineered Hello World in C 46&lt;span id="cb3-6"&gt;&lt;a href="#cb3-6" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="ex"&gt;├───c-hello:&lt;/span&gt; template: An over-engineered Hello World in C&lt;/span&gt;
47 ├───rust-web-server: template: A Rust web server including a NixOS module 47&lt;span id="cb3-7"&gt;&lt;a href="#cb3-7" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="ex"&gt;├───rust-web-server:&lt;/span&gt; template: A Rust web server including a NixOS module&lt;/span&gt;
48 ├───simpleContainer: template: A NixOS container running apache-httpd 48&lt;span id="cb3-8"&gt;&lt;a href="#cb3-8" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="ex"&gt;├───simpleContainer:&lt;/span&gt; template: A NixOS container running apache-httpd&lt;/span&gt;
49 └───trivial: template: A very basic flake&lt;/code&gt;&lt;/pre&gt; 49&lt;span id="cb3-9"&gt;&lt;a href="#cb3-9" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="ex"&gt;└───trivial:&lt;/span&gt; template: A very basic flake&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
50&lt;p&gt;Aha! There is a flake output called &lt;code&gt;defaultTemplate&lt;/code&gt;. This is the template being sourced when you run &lt;code&gt;nix flake init&lt;/code&gt;. Astute readers may conclude the following:&lt;/p&gt; 50&lt;p&gt;Aha! There is a flake output called &lt;code&gt;defaultTemplate&lt;/code&gt;. This is the template being sourced when you run &lt;code&gt;nix flake init&lt;/code&gt;. Astute readers may conclude the following:&lt;/p&gt;
51&lt;pre&gt;&lt;code&gt;$ nix flake init 51&lt;div class="sourceCode" id="cb4"&gt;&lt;pre class="sourceCode bash"&gt;&lt;code class="sourceCode bash"&gt;&lt;span id="cb4-1"&gt;&lt;a href="#cb4-1" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;$&lt;/span&gt; nix flake init&lt;/span&gt;
52 52&lt;span id="cb4-2"&gt;&lt;a href="#cb4-2" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;/span&gt;
53# is equivalent to 53&lt;span id="cb4-3"&gt;&lt;a href="#cb4-3" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="co"&gt;# is equivalent to&lt;/span&gt;&lt;/span&gt;
54$ nix flake init -t templates#defaultTemplate 54&lt;span id="cb4-4"&gt;&lt;a href="#cb4-4" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;$&lt;/span&gt; nix flake init &lt;span class="at"&gt;-t&lt;/span&gt; templates#defaultTemplate&lt;/span&gt;
55 55&lt;span id="cb4-5"&gt;&lt;a href="#cb4-5" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;/span&gt;
56# is equivalent to 56&lt;span id="cb4-6"&gt;&lt;a href="#cb4-6" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="co"&gt;# is equivalent to&lt;/span&gt;&lt;/span&gt;
57$ nix flake init -t github:NixOS/templates#defaultTemplate 57&lt;span id="cb4-7"&gt;&lt;a href="#cb4-7" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;$&lt;/span&gt; nix flake init &lt;span class="at"&gt;-t&lt;/span&gt; github:NixOS/templates#defaultTemplate&lt;/span&gt;
58 58&lt;span id="cb4-8"&gt;&lt;a href="#cb4-8" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;/span&gt;
59# which is short for 59&lt;span id="cb4-9"&gt;&lt;a href="#cb4-9" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="co"&gt;# which is short for&lt;/span&gt;&lt;/span&gt;
60$ nix flake init -t git+https://NixOS/templates#defaultTemplate&lt;/code&gt;&lt;/pre&gt; 60&lt;span id="cb4-10"&gt;&lt;a href="#cb4-10" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;$&lt;/span&gt; nix flake init &lt;span class="at"&gt;-t&lt;/span&gt; git+https://NixOS/templates#defaultTemplate&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
61&lt;p&gt;Similarly, the other templates can be accessed via:&lt;/p&gt; 61&lt;p&gt;Similarly, the other templates can be accessed via:&lt;/p&gt;
62&lt;pre&gt;&lt;code&gt;$ nix flake init -t templates#c-hello 62&lt;div class="sourceCode" id="cb5"&gt;&lt;pre class="sourceCode bash"&gt;&lt;code class="sourceCode bash"&gt;&lt;span id="cb5-1"&gt;&lt;a href="#cb5-1" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;$&lt;/span&gt; nix flake init &lt;span class="at"&gt;-t&lt;/span&gt; templates#c-hello&lt;/span&gt;
63$ nix flake init -t templates#simpleContainer 63&lt;span id="cb5-2"&gt;&lt;a href="#cb5-2" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;$&lt;/span&gt; nix flake init &lt;span class="at"&gt;-t&lt;/span&gt; templates#simpleContainer&lt;/span&gt;
64# I think you get the drift ...&lt;/code&gt;&lt;/pre&gt; 64&lt;span id="cb5-3"&gt;&lt;a href="#cb5-3" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="co"&gt;# I think you get the drift ...&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
65&lt;h2 id="rolling-your-own-templates"&gt;Rolling your own templates&lt;/h2&gt; 65&lt;h2 id="rolling-your-own-templates"&gt;Rolling your own templates&lt;/h2&gt;
66&lt;p&gt;Alright, so all we need to do is:&lt;/p&gt; 66&lt;p&gt;Alright, so all we need to do is:&lt;/p&gt;
67&lt;ul&gt; 67&lt;ul&gt;
@@ -70,94 +70,94 @@ $ nix flake init -t templates#simpleContainer
70&lt;li&gt;(&lt;strong&gt;optionally&lt;/strong&gt;) alias our custom templates flake to an identifier using registries, for easier access&lt;/li&gt; 70&lt;li&gt;(&lt;strong&gt;optionally&lt;/strong&gt;) alias our custom templates flake to an identifier using registries, for easier access&lt;/li&gt;
71&lt;/ul&gt; 71&lt;/ul&gt;
72&lt;p&gt;Start off by creating a directory to store your templates in (we will be converting this to a registry later):&lt;/p&gt; 72&lt;p&gt;Start off by creating a directory to store your templates in (we will be converting this to a registry later):&lt;/p&gt;
73&lt;pre&gt;&lt;code&gt;$ mkdir ~/mytemplates&lt;/code&gt;&lt;/pre&gt; 73&lt;div class="sourceCode" id="cb6"&gt;&lt;pre class="sourceCode bash"&gt;&lt;code class="sourceCode bash"&gt;&lt;span id="cb6-1"&gt;&lt;a href="#cb6-1" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;$&lt;/span&gt; mkdir ~/mytemplates&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
74&lt;p&gt;A flake that exposes a “template” as its output looks something like this:&lt;/p&gt; 74&lt;p&gt;A flake that exposes a “template” as its output looks something like this:&lt;/p&gt;
75&lt;pre&gt;&lt;code&gt;# inside ~/mytemplates/flake.nix 75&lt;div class="sourceCode" id="cb7"&gt;&lt;pre class="sourceCode nix"&gt;&lt;code class="sourceCode bash"&gt;&lt;span id="cb7-1"&gt;&lt;a href="#cb7-1" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="co"&gt;# inside ~/mytemplates/flake.nix&lt;/span&gt;&lt;/span&gt;
76 76&lt;span id="cb7-2"&gt;&lt;a href="#cb7-2" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;/span&gt;
77{ 77&lt;span id="cb7-3"&gt;&lt;a href="#cb7-3" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="kw"&gt;{&lt;/span&gt;&lt;/span&gt;
78 description = &amp;quot;Pepper&amp;#39;s flake templates&amp;quot;; 78&lt;span id="cb7-4"&gt;&lt;a href="#cb7-4" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="ex"&gt;description&lt;/span&gt; = &lt;span class="st"&gt;&amp;quot;Pepper&amp;#39;s flake templates&amp;quot;&lt;/span&gt;&lt;span class="kw"&gt;;&lt;/span&gt;&lt;/span&gt;
79 79&lt;span id="cb7-5"&gt;&lt;a href="#cb7-5" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;/span&gt;
80 outputs = { self, ... }: { 80&lt;span id="cb7-6"&gt;&lt;a href="#cb7-6" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="ex"&gt;outputs&lt;/span&gt; = { self, ... }: {&lt;/span&gt;
81 templates = { 81&lt;span id="cb7-7"&gt;&lt;a href="#cb7-7" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="ex"&gt;templates&lt;/span&gt; = {&lt;/span&gt;
82 latex-report = { 82&lt;span id="cb7-8"&gt;&lt;a href="#cb7-8" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="ex"&gt;latex-report&lt;/span&gt; = {&lt;/span&gt;
83 path = ./latex-report-template; 83&lt;span id="cb7-9"&gt;&lt;a href="#cb7-9" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="ex"&gt;path&lt;/span&gt; = ./latex-report-template&lt;span class="kw"&gt;;&lt;/span&gt;&lt;/span&gt;
84 description = &amp;quot;A latex whitepaper project&amp;quot;; 84&lt;span id="cb7-10"&gt;&lt;a href="#cb7-10" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="ex"&gt;description&lt;/span&gt; = &lt;span class="st"&gt;&amp;quot;A latex whitepaper project&amp;quot;&lt;/span&gt;&lt;span class="kw"&gt;;&lt;/span&gt;&lt;/span&gt;
85 }; 85&lt;span id="cb7-11"&gt;&lt;a href="#cb7-11" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="kw"&gt;};&lt;/span&gt;&lt;/span&gt;
86 rust-hello = { 86&lt;span id="cb7-12"&gt;&lt;a href="#cb7-12" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="ex"&gt;rust-hello&lt;/span&gt; = {&lt;/span&gt;
87 path = ./rust-hello-template; 87&lt;span id="cb7-13"&gt;&lt;a href="#cb7-13" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="ex"&gt;path&lt;/span&gt; = ./rust-hello-template&lt;span class="kw"&gt;;&lt;/span&gt;&lt;/span&gt;
88 description = &amp;quot;Simple Hello World in Rust&amp;quot;; 88&lt;span id="cb7-14"&gt;&lt;a href="#cb7-14" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="ex"&gt;description&lt;/span&gt; = &lt;span class="st"&gt;&amp;quot;Simple Hello World in Rust&amp;quot;&lt;/span&gt;&lt;span class="kw"&gt;;&lt;/span&gt;&lt;/span&gt;
89 }; 89&lt;span id="cb7-15"&gt;&lt;a href="#cb7-15" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="er"&gt;}&lt;/span&gt;&lt;span class="kw"&gt;;&lt;/span&gt;&lt;/span&gt;
90 }; 90&lt;span id="cb7-16"&gt;&lt;a href="#cb7-16" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="er"&gt;}&lt;/span&gt;&lt;span class="kw"&gt;;&lt;/span&gt;&lt;/span&gt;
91 }; 91&lt;span id="cb7-17"&gt;&lt;a href="#cb7-17" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="er"&gt;}&lt;/span&gt;&lt;span class="kw"&gt;;&lt;/span&gt;&lt;/span&gt;
92}&lt;/code&gt;&lt;/pre&gt; 92&lt;span id="cb7-18"&gt;&lt;a href="#cb7-18" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="er"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
93&lt;p&gt;The &lt;code&gt;path&lt;/code&gt; attribute to each template is what gets copied over when you initialize a flake. Running &lt;code&gt;nix flake init -t .#latex-report&lt;/code&gt; will initialize the current directory with the contents of &lt;code&gt;./latex-report-template&lt;/code&gt; (we are yet to populate these directories).&lt;/p&gt; 93&lt;p&gt;The &lt;code&gt;path&lt;/code&gt; attribute to each template is what gets copied over when you initialize a flake. Running &lt;code&gt;nix flake init -t .#latex-report&lt;/code&gt; will initialize the current directory with the contents of &lt;code&gt;./latex-report-template&lt;/code&gt; (we are yet to populate these directories).&lt;/p&gt;
94&lt;p&gt;The output of &lt;code&gt;nix flake show&lt;/code&gt; should be something like:&lt;/p&gt; 94&lt;p&gt;The output of &lt;code&gt;nix flake show&lt;/code&gt; should be something like:&lt;/p&gt;
95&lt;pre&gt;&lt;code&gt;$ nix flake show 95&lt;div class="sourceCode" id="cb8"&gt;&lt;pre class="sourceCode bash"&gt;&lt;code class="sourceCode bash"&gt;&lt;span id="cb8-1"&gt;&lt;a href="#cb8-1" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;$&lt;/span&gt; nix flake show&lt;/span&gt;
96path:/home/np/code/nix-stuff/template-tests?narHash=sha256-{...} 96&lt;span id="cb8-2"&gt;&lt;a href="#cb8-2" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;path:/home/np/code/nix-stuff/template-tests?narHash=sha256-{...}&lt;/span&gt;&lt;/span&gt;
97└───templates 97&lt;span id="cb8-3"&gt;&lt;a href="#cb8-3" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;└───templates&lt;/span&gt;&lt;/span&gt;
98 ├───latex-report: template: A latex whitepaper project 98&lt;span id="cb8-4"&gt;&lt;a href="#cb8-4" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="ex"&gt;├───latex-report:&lt;/span&gt; template: A latex whitepaper project&lt;/span&gt;
99 └───rust-hello: template: Simple Hello World in Rust&lt;/code&gt;&lt;/pre&gt; 99&lt;span id="cb8-5"&gt;&lt;a href="#cb8-5" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="ex"&gt;└───rust-hello:&lt;/span&gt; template: Simple Hello World in Rust&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
100&lt;p&gt;Populate your template directories with content, here are my template directories for example:&lt;/p&gt; 100&lt;p&gt;Populate your template directories with content, here are my template directories for example:&lt;/p&gt;
101&lt;pre&gt;&lt;code&gt;$ tree mytemplates 101&lt;div class="sourceCode" id="cb9"&gt;&lt;pre class="sourceCode bash"&gt;&lt;code class="sourceCode bash"&gt;&lt;span id="cb9-1"&gt;&lt;a href="#cb9-1" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;$&lt;/span&gt; tree mytemplates&lt;/span&gt;
102mytemplates/ 102&lt;span id="cb9-2"&gt;&lt;a href="#cb9-2" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;mytemplates/&lt;/span&gt;&lt;/span&gt;
103├── flake.nix 103&lt;span id="cb9-3"&gt;&lt;a href="#cb9-3" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;├──&lt;/span&gt; flake.nix&lt;/span&gt;
104├── latex-report-template 104&lt;span id="cb9-4"&gt;&lt;a href="#cb9-4" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;├──&lt;/span&gt; latex-report-template&lt;/span&gt;
105│   ├── flake.nix 105&lt;span id="cb9-5"&gt;&lt;a href="#cb9-5" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;│  &lt;/span&gt; ├── flake.nix&lt;/span&gt;
106│   ├── makefile 106&lt;span id="cb9-6"&gt;&lt;a href="#cb9-6" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;│  &lt;/span&gt; ├── makefile&lt;/span&gt;
107│   └── src 107&lt;span id="cb9-7"&gt;&lt;a href="#cb9-7" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;│  &lt;/span&gt; └── src&lt;/span&gt;
108│   ├── meta.sty 108&lt;span id="cb9-8"&gt;&lt;a href="#cb9-8" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;│  &lt;/span&gt; ├── meta.sty&lt;/span&gt;
109│   └── report.tex 109&lt;span id="cb9-9"&gt;&lt;a href="#cb9-9" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;│  &lt;/span&gt; └── report.tex&lt;/span&gt;
110└── rust-hello-template 110&lt;span id="cb9-10"&gt;&lt;a href="#cb9-10" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;└──&lt;/span&gt; rust-hello-template&lt;/span&gt;
111 ├── Cargo.toml 111&lt;span id="cb9-11"&gt;&lt;a href="#cb9-11" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="ex"&gt;├──&lt;/span&gt; Cargo.toml&lt;/span&gt;
112 ├── flake.nix 112&lt;span id="cb9-12"&gt;&lt;a href="#cb9-12" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="ex"&gt;├──&lt;/span&gt; flake.nix&lt;/span&gt;
113 └── src 113&lt;span id="cb9-13"&gt;&lt;a href="#cb9-13" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="ex"&gt;└──&lt;/span&gt; src&lt;/span&gt;
114 └── main.rs&lt;/code&gt;&lt;/pre&gt; 114&lt;span id="cb9-14"&gt;&lt;a href="#cb9-14" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="ex"&gt;└──&lt;/span&gt; main.rs&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
115&lt;p&gt;And that’s it! Start using your templates with:&lt;/p&gt; 115&lt;p&gt;And that’s it! Start using your templates with:&lt;/p&gt;
116&lt;pre&gt;&lt;code&gt;$ nix flake init -t ~/mytemplates#rust-hello 116&lt;div class="sourceCode" id="cb10"&gt;&lt;pre class="sourceCode bash"&gt;&lt;code class="sourceCode bash"&gt;&lt;span id="cb10-1"&gt;&lt;a href="#cb10-1" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;$&lt;/span&gt; nix flake init &lt;span class="at"&gt;-t&lt;/span&gt; ~/mytemplates#rust-hello&lt;/span&gt;
117$ tree . 117&lt;span id="cb10-2"&gt;&lt;a href="#cb10-2" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;$&lt;/span&gt; tree .&lt;/span&gt;
118. 118&lt;span id="cb10-3"&gt;&lt;a href="#cb10-3" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="bu"&gt;.&lt;/span&gt;&lt;/span&gt;
119├── Cargo.toml 119&lt;span id="cb10-4"&gt;&lt;a href="#cb10-4" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;├──&lt;/span&gt; Cargo.toml&lt;/span&gt;
120├── flake.nix 120&lt;span id="cb10-5"&gt;&lt;a href="#cb10-5" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;├──&lt;/span&gt; flake.nix&lt;/span&gt;
121└── src 121&lt;span id="cb10-6"&gt;&lt;a href="#cb10-6" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;└──&lt;/span&gt; src&lt;/span&gt;
122 └── main.rs&lt;/code&gt;&lt;/pre&gt; 122&lt;span id="cb10-7"&gt;&lt;a href="#cb10-7" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="ex"&gt;└──&lt;/span&gt; main.rs&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
123&lt;p&gt;To avoid writing &lt;code&gt;~/mytemplates&lt;/code&gt; each time, simply alias it to a registry:&lt;/p&gt; 123&lt;p&gt;To avoid writing &lt;code&gt;~/mytemplates&lt;/code&gt; each time, simply alias it to a registry:&lt;/p&gt;
124&lt;pre&gt;&lt;code&gt;# alias it to `biscuits` 124&lt;div class="sourceCode" id="cb11"&gt;&lt;pre class="sourceCode bash"&gt;&lt;code class="sourceCode bash"&gt;&lt;span id="cb11-1"&gt;&lt;a href="#cb11-1" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="co"&gt;# alias it to `biscuits`&lt;/span&gt;&lt;/span&gt;
125$ nix registry add biscuits ~/mytemplates 125&lt;span id="cb11-2"&gt;&lt;a href="#cb11-2" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;$&lt;/span&gt; nix registry add biscuits ~/mytemplates&lt;/span&gt;
126 126&lt;span id="cb11-3"&gt;&lt;a href="#cb11-3" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;/span&gt;
127# you will see it listed under `user` registries 127&lt;span id="cb11-4"&gt;&lt;a href="#cb11-4" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="co"&gt;# you will see it listed under `user` registries&lt;/span&gt;&lt;/span&gt;
128$ nix registry list 128&lt;span id="cb11-5"&gt;&lt;a href="#cb11-5" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;$&lt;/span&gt; nix registry list&lt;/span&gt;
129. . . 129&lt;span id="cb11-6"&gt;&lt;a href="#cb11-6" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="bu"&gt;.&lt;/span&gt; . .&lt;/span&gt;
130user flake:biscuits path:/home/np/template-tests 130&lt;span id="cb11-7"&gt;&lt;a href="#cb11-7" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;user&lt;/span&gt; flake:biscuits path:/home/np/template-tests&lt;/span&gt;
131. . . 131&lt;span id="cb11-8"&gt;&lt;a href="#cb11-8" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="bu"&gt;.&lt;/span&gt; . .&lt;/span&gt;
132 132&lt;span id="cb11-9"&gt;&lt;a href="#cb11-9" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;/span&gt;
133$ nix flake init -t biscuits#latex-report&lt;/code&gt;&lt;/pre&gt; 133&lt;span id="cb11-10"&gt;&lt;a href="#cb11-10" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;$&lt;/span&gt; nix flake init &lt;span class="at"&gt;-t&lt;/span&gt; biscuits#latex-report&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
134&lt;h2 id="extending-the-official-templates"&gt;Extending the official templates&lt;/h2&gt; 134&lt;h2 id="extending-the-official-templates"&gt;Extending the official templates&lt;/h2&gt;
135&lt;p&gt;I personally, would like the &lt;code&gt;biscuits&lt;/code&gt; registry to include not just my homemade templates, but also the templates from &lt;code&gt;NixOS/templates&lt;/code&gt; (and maybe a couple of other repositories in the wild):&lt;/p&gt; 135&lt;p&gt;I personally, would like the &lt;code&gt;biscuits&lt;/code&gt; registry to include not just my homemade templates, but also the templates from &lt;code&gt;NixOS/templates&lt;/code&gt; (and maybe a couple of other repositories in the wild):&lt;/p&gt;
136&lt;pre&gt;&lt;code&gt; { 136&lt;div class="sourceCode" id="cb12"&gt;&lt;pre class="sourceCode nix"&gt;&lt;code class="sourceCode bash"&gt;&lt;span id="cb12-1"&gt;&lt;a href="#cb12-1" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="kw"&gt;{&lt;/span&gt;&lt;/span&gt;
137 description = &amp;quot;Pepper&amp;#39;s flake templates&amp;quot;; 137&lt;span id="cb12-2"&gt;&lt;a href="#cb12-2" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="ex"&gt;description&lt;/span&gt; = &lt;span class="st"&gt;&amp;quot;Pepper&amp;#39;s flake templates&amp;quot;&lt;/span&gt;&lt;span class="kw"&gt;;&lt;/span&gt;&lt;/span&gt;
138 138&lt;span id="cb12-3"&gt;&lt;a href="#cb12-3" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;/span&gt;
139+ inputs = { 139&lt;span id="cb12-4"&gt;&lt;a href="#cb12-4" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;+&lt;/span&gt; inputs = {&lt;/span&gt;
140+ official-templates.url = github:NixOS/templates; 140&lt;span id="cb12-5"&gt;&lt;a href="#cb12-5" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;+&lt;/span&gt; official-templates.url = github:NixOS/templates&lt;span class="kw"&gt;;&lt;/span&gt;&lt;/span&gt;
141+ other-templates.url = github:some-other/templates; 141&lt;span id="cb12-6"&gt;&lt;a href="#cb12-6" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;+&lt;/span&gt; other-templates.url = github:some-other/templates&lt;span class="kw"&gt;;&lt;/span&gt;&lt;/span&gt;
142+ }; 142&lt;span id="cb12-7"&gt;&lt;a href="#cb12-7" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;+&lt;/span&gt; }&lt;span class="kw"&gt;;&lt;/span&gt;&lt;/span&gt;
143 143&lt;span id="cb12-8"&gt;&lt;a href="#cb12-8" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;/span&gt;
144 outputs = { self, official-templates, other-templates ... }: { 144&lt;span id="cb12-9"&gt;&lt;a href="#cb12-9" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="ex"&gt;outputs&lt;/span&gt; = { self, official-templates, other-templates ... }: {&lt;/span&gt;
145 145&lt;span id="cb12-10"&gt;&lt;a href="#cb12-10" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;/span&gt;
146 templates = { 146&lt;span id="cb12-11"&gt;&lt;a href="#cb12-11" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="ex"&gt;templates&lt;/span&gt; = {&lt;/span&gt;
147 latex-report = { 147&lt;span id="cb12-12"&gt;&lt;a href="#cb12-12" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="ex"&gt;latex-report&lt;/span&gt; = {&lt;/span&gt;
148 path = ./latex-report-template; 148&lt;span id="cb12-13"&gt;&lt;a href="#cb12-13" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="ex"&gt;path&lt;/span&gt; = ./latex-report-template&lt;span class="kw"&gt;;&lt;/span&gt;&lt;/span&gt;
149 description = &amp;quot;A latex whitepaper project&amp;quot;; 149&lt;span id="cb12-14"&gt;&lt;a href="#cb12-14" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="ex"&gt;description&lt;/span&gt; = &lt;span class="st"&gt;&amp;quot;A latex whitepaper project&amp;quot;&lt;/span&gt;&lt;span class="kw"&gt;;&lt;/span&gt;&lt;/span&gt;
150 }; 150&lt;span id="cb12-15"&gt;&lt;a href="#cb12-15" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="kw"&gt;};&lt;/span&gt;&lt;/span&gt;
151 rust-hello = { 151&lt;span id="cb12-16"&gt;&lt;a href="#cb12-16" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="ex"&gt;rust-hello&lt;/span&gt; = {&lt;/span&gt;
152 path = ./rust-hello-template; 152&lt;span id="cb12-17"&gt;&lt;a href="#cb12-17" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="ex"&gt;path&lt;/span&gt; = ./rust-hello-template&lt;span class="kw"&gt;;&lt;/span&gt;&lt;/span&gt;
153 description = &amp;quot;Simple Hello World in Rust, with overloaded Rust toolchain&amp;quot;; 153&lt;span id="cb12-18"&gt;&lt;a href="#cb12-18" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="ex"&gt;description&lt;/span&gt; = &lt;span class="st"&gt;&amp;quot;Simple Hello World in Rust, with overloaded Rust toolchain&amp;quot;&lt;/span&gt;&lt;span class="kw"&gt;;&lt;/span&gt;&lt;/span&gt;
154 }; 154&lt;span id="cb12-19"&gt;&lt;a href="#cb12-19" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="er"&gt;}&lt;/span&gt;&lt;span class="kw"&gt;;&lt;/span&gt;&lt;/span&gt;
155 } 155&lt;span id="cb12-20"&gt;&lt;a href="#cb12-20" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="er"&gt;}&lt;/span&gt;&lt;/span&gt;
156+ // official-templates.templates 156&lt;span id="cb12-21"&gt;&lt;a href="#cb12-21" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;+&lt;/span&gt; // official-templates.templates&lt;/span&gt;
157+ // other-templates.templates; 157&lt;span id="cb12-22"&gt;&lt;a href="#cb12-22" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;+&lt;/span&gt; // other-templates.templates&lt;span class="kw"&gt;;&lt;/span&gt;&lt;/span&gt;
158 158&lt;span id="cb12-23"&gt;&lt;a href="#cb12-23" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;/span&gt;
159 }; 159&lt;span id="cb12-24"&gt;&lt;a href="#cb12-24" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="er"&gt;}&lt;/span&gt;&lt;span class="kw"&gt;;&lt;/span&gt;&lt;/span&gt;
160 }&lt;/code&gt;&lt;/pre&gt; 160&lt;span id="cb12-25"&gt;&lt;a href="#cb12-25" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="er"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
161&lt;p&gt;Running &lt;code&gt;nix flake show biscuits&lt;/code&gt; will now list templates from the &lt;code&gt;biscuits&lt;/code&gt; registry as well as the ones from &lt;code&gt;NixOS/templates&lt;/code&gt;. Ensure that the names don’t collide though.&lt;/p&gt;</description> 161&lt;p&gt;Running &lt;code&gt;nix flake show biscuits&lt;/code&gt; will now list templates from the &lt;code&gt;biscuits&lt;/code&gt; registry as well as the ones from &lt;code&gt;NixOS/templates&lt;/code&gt;. Ensure that the names don’t collide though.&lt;/p&gt;</description>
162<link>https://peppe.rs/posts/novice_nix:_flake_templates/</link> 162<link>https://peppe.rs/posts/novice_nix:_flake_templates/</link>
163<pubDate>Tue, 05 Oct 2021 16:49:00 +0000</pubDate> 163<pubDate>Tue, 05 Oct 2021 16:49:00 +0000</pubDate>
diff --git a/docs/posts/novice_nix:_flake_templates/index.html b/docs/posts/novice_nix:_flake_templates/index.html
index f71c13a..6e1a49d 100644
--- a/docs/posts/novice_nix:_flake_templates/index.html
+++ b/docs/posts/novice_nix:_flake_templates/index.html
@@ -44,53 +44,53 @@
44 <div class="post-text"> 44 <div class="post-text">
45 <p>Flakes are very handy to setup entirely pure, project-specific dependencies (not just dependencies, but build steps, shell environments and more) in a declarative way. Writing Flake expressions can get repetitive though, oftentimes, you’d much rather start off with a skeleton. Luckily, <code>nix</code> already supports templates!</p> 45 <p>Flakes are very handy to setup entirely pure, project-specific dependencies (not just dependencies, but build steps, shell environments and more) in a declarative way. Writing Flake expressions can get repetitive though, oftentimes, you’d much rather start off with a skeleton. Luckily, <code>nix</code> already supports templates!</p>
46<p>You might already be familiar with <code>nix flake init</code>, that drops a “default” flake expression into your current working directory. If you head over to the manpage:</p> 46<p>You might already be familiar with <code>nix flake init</code>, that drops a “default” flake expression into your current working directory. If you head over to the manpage:</p>
47<pre><code>nix flake init --help</code></pre> 47<div class="sourceCode" id="cb1"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="ex">nix</span> flake init <span class="at">--help</span></span></code></pre></div>
48<p>You will read that <code>nix flake init</code> creates a flake using the “default template”. Additionally, you can create a flake from a specific template by passing the <code>-t</code> flag. Where does this default originate from?</p> 48<p>You will read that <code>nix flake init</code> creates a flake using the “default template”. Additionally, you can create a flake from a specific template by passing the <code>-t</code> flag. Where does this default originate from?</p>
49<h2 id="flake-registries">Flake Registries</h2> 49<h2 id="flake-registries">Flake Registries</h2>
50<p>Quick detour into registries! Registries are a way to alias popular flakes using identifiers:</p> 50<p>Quick detour into registries! Registries are a way to alias popular flakes using identifiers:</p>
51<pre><code># list a few predefined registries 51<div class="sourceCode" id="cb2"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="co"># list a few predefined registries</span></span>
52$ nix registry list 52<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> nix registry list</span>
53. . . 53<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a><span class="bu">.</span> . . </span>
54global flake:nixpkgs github:NixOS/nixpkgs 54<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a><span class="ex">global</span> flake:nixpkgs github:NixOS/nixpkgs</span>
55global flake:patchelf github:NixOS/patchelf 55<span id="cb2-5"><a href="#cb2-5" aria-hidden="true" tabindex="-1"></a><span class="ex">global</span> flake:patchelf github:NixOS/patchelf</span>
56global flake:nix-serve github:edolstra/nix-serve 56<span id="cb2-6"><a href="#cb2-6" aria-hidden="true" tabindex="-1"></a><span class="ex">global</span> flake:nix-serve github:edolstra/nix-serve</span>
57global flake:templates github:NixOS/templates 57<span id="cb2-7"><a href="#cb2-7" aria-hidden="true" tabindex="-1"></a><span class="ex">global</span> flake:templates github:NixOS/templates</span>
58global flake:nickel github:tweag/nickel 58<span id="cb2-8"><a href="#cb2-8" aria-hidden="true" tabindex="-1"></a><span class="ex">global</span> flake:nickel github:tweag/nickel</span>
59. . . 59<span id="cb2-9"><a href="#cb2-9" aria-hidden="true" tabindex="-1"></a><span class="bu">.</span> . .</span>
60 60<span id="cb2-10"><a href="#cb2-10" aria-hidden="true" tabindex="-1"></a></span>
61# you can do 61<span id="cb2-11"><a href="#cb2-11" aria-hidden="true" tabindex="-1"></a><span class="co"># you can do </span></span>
62$ nix flake show nickel 62<span id="cb2-12"><a href="#cb2-12" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> nix flake show nickel</span>
63 63<span id="cb2-13"><a href="#cb2-13" aria-hidden="true" tabindex="-1"></a></span>
64# instead of 64<span id="cb2-14"><a href="#cb2-14" aria-hidden="true" tabindex="-1"></a><span class="co"># instead of </span></span>
65$ nix flake show github:tweag/nickel 65<span id="cb2-15"><a href="#cb2-15" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> nix flake show github:tweag/nickel</span>
66 66<span id="cb2-16"><a href="#cb2-16" aria-hidden="true" tabindex="-1"></a></span>
67# which is short for 67<span id="cb2-17"><a href="#cb2-17" aria-hidden="true" tabindex="-1"></a><span class="co"># which is short for</span></span>
68$ nix flake show git+https://github.com/tweag/nickel</code></pre> 68<span id="cb2-18"><a href="#cb2-18" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> nix flake show git+https://github.com/tweag/nickel</span></code></pre></div>
69<p>You might notice a registry called <code>templates</code> aliased to <code>github:NixOS/templates</code>. Take a peek with <code>nix flake show</code>:</p> 69<p>You might notice a registry called <code>templates</code> aliased to <code>github:NixOS/templates</code>. Take a peek with <code>nix flake show</code>:</p>
70<pre><code>$ nix flake show templates 70<div class="sourceCode" id="cb3"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> nix flake show templates</span>
71github:NixOS/templates/79f48a7b822f35c068c5e235da2e9fbd154cecee 71<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a><span class="ex">github:NixOS/templates/79f48a7b822f35c068c5e235da2e9fbd154cecee</span></span>
72├───defaultTemplate: template: A very basic flake 72<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a><span class="ex">├───defaultTemplate:</span> template: A very basic flake</span>
73└───templates 73<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a><span class="ex">└───templates</span></span>
74 ├───bash-hello: template: An over-engineered Hello World in bash 74<span id="cb3-5"><a href="#cb3-5" aria-hidden="true" tabindex="-1"></a> <span class="ex">├───bash-hello:</span> template: An over-engineered Hello World in bash</span>
75 ├───c-hello: template: An over-engineered Hello World in C 75<span id="cb3-6"><a href="#cb3-6" aria-hidden="true" tabindex="-1"></a> <span class="ex">├───c-hello:</span> template: An over-engineered Hello World in C</span>
76 ├───rust-web-server: template: A Rust web server including a NixOS module 76<span id="cb3-7"><a href="#cb3-7" aria-hidden="true" tabindex="-1"></a> <span class="ex">├───rust-web-server:</span> template: A Rust web server including a NixOS module</span>
77 ├───simpleContainer: template: A NixOS container running apache-httpd 77<span id="cb3-8"><a href="#cb3-8" aria-hidden="true" tabindex="-1"></a> <span class="ex">├───simpleContainer:</span> template: A NixOS container running apache-httpd</span>
78 └───trivial: template: A very basic flake</code></pre> 78<span id="cb3-9"><a href="#cb3-9" aria-hidden="true" tabindex="-1"></a> <span class="ex">└───trivial:</span> template: A very basic flake</span></code></pre></div>
79<p>Aha! There is a flake output called <code>defaultTemplate</code>. This is the template being sourced when you run <code>nix flake init</code>. Astute readers may conclude the following:</p> 79<p>Aha! There is a flake output called <code>defaultTemplate</code>. This is the template being sourced when you run <code>nix flake init</code>. Astute readers may conclude the following:</p>
80<pre><code>$ nix flake init 80<div class="sourceCode" id="cb4"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> nix flake init</span>
81 81<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a></span>
82# is equivalent to 82<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a><span class="co"># is equivalent to</span></span>
83$ nix flake init -t templates#defaultTemplate 83<span id="cb4-4"><a href="#cb4-4" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> nix flake init <span class="at">-t</span> templates#defaultTemplate</span>
84 84<span id="cb4-5"><a href="#cb4-5" aria-hidden="true" tabindex="-1"></a></span>
85# is equivalent to 85<span id="cb4-6"><a href="#cb4-6" aria-hidden="true" tabindex="-1"></a><span class="co"># is equivalent to</span></span>
86$ nix flake init -t github:NixOS/templates#defaultTemplate 86<span id="cb4-7"><a href="#cb4-7" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> nix flake init <span class="at">-t</span> github:NixOS/templates#defaultTemplate</span>
87 87<span id="cb4-8"><a href="#cb4-8" aria-hidden="true" tabindex="-1"></a></span>
88# which is short for 88<span id="cb4-9"><a href="#cb4-9" aria-hidden="true" tabindex="-1"></a><span class="co"># which is short for</span></span>
89$ nix flake init -t git+https://NixOS/templates#defaultTemplate</code></pre> 89<span id="cb4-10"><a href="#cb4-10" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> nix flake init <span class="at">-t</span> git+https://NixOS/templates#defaultTemplate</span></code></pre></div>
90<p>Similarly, the other templates can be accessed via:</p> 90<p>Similarly, the other templates can be accessed via:</p>
91<pre><code>$ nix flake init -t templates#c-hello 91<div class="sourceCode" id="cb5"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> nix flake init <span class="at">-t</span> templates#c-hello</span>
92$ nix flake init -t templates#simpleContainer 92<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> nix flake init <span class="at">-t</span> templates#simpleContainer</span>
93# I think you get the drift ...</code></pre> 93<span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a><span class="co"># I think you get the drift ...</span></span></code></pre></div>
94<h2 id="rolling-your-own-templates">Rolling your own templates</h2> 94<h2 id="rolling-your-own-templates">Rolling your own templates</h2>
95<p>Alright, so all we need to do is:</p> 95<p>Alright, so all we need to do is:</p>
96<ul> 96<ul>
@@ -99,94 +99,94 @@ $ nix flake init -t templates#simpleContainer
99<li>(<strong>optionally</strong>) alias our custom templates flake to an identifier using registries, for easier access</li> 99<li>(<strong>optionally</strong>) alias our custom templates flake to an identifier using registries, for easier access</li>
100</ul> 100</ul>
101<p>Start off by creating a directory to store your templates in (we will be converting this to a registry later):</p> 101<p>Start off by creating a directory to store your templates in (we will be converting this to a registry later):</p>
102<pre><code>$ mkdir ~/mytemplates</code></pre> 102<div class="sourceCode" id="cb6"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> mkdir ~/mytemplates</span></code></pre></div>
103<p>A flake that exposes a “template” as its output looks something like this:</p> 103<p>A flake that exposes a “template” as its output looks something like this:</p>
104<pre><code># inside ~/mytemplates/flake.nix 104<div class="sourceCode" id="cb7"><pre class="sourceCode nix"><code class="sourceCode bash"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a><span class="co"># inside ~/mytemplates/flake.nix</span></span>
105 105<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a></span>
106{ 106<span id="cb7-3"><a href="#cb7-3" aria-hidden="true" tabindex="-1"></a><span class="kw">{</span></span>
107 description = &quot;Pepper&#39;s flake templates&quot;; 107<span id="cb7-4"><a href="#cb7-4" aria-hidden="true" tabindex="-1"></a> <span class="ex">description</span> = <span class="st">&quot;Pepper&#39;s flake templates&quot;</span><span class="kw">;</span></span>
108 108<span id="cb7-5"><a href="#cb7-5" aria-hidden="true" tabindex="-1"></a></span>
109 outputs = { self, ... }: { 109<span id="cb7-6"><a href="#cb7-6" aria-hidden="true" tabindex="-1"></a> <span class="ex">outputs</span> = { self, ... }: {</span>
110 templates = { 110<span id="cb7-7"><a href="#cb7-7" aria-hidden="true" tabindex="-1"></a> <span class="ex">templates</span> = {</span>
111 latex-report = { 111<span id="cb7-8"><a href="#cb7-8" aria-hidden="true" tabindex="-1"></a> <span class="ex">latex-report</span> = {</span>
112 path = ./latex-report-template; 112<span id="cb7-9"><a href="#cb7-9" aria-hidden="true" tabindex="-1"></a> <span class="ex">path</span> = ./latex-report-template<span class="kw">;</span></span>
113 description = &quot;A latex whitepaper project&quot;; 113<span id="cb7-10"><a href="#cb7-10" aria-hidden="true" tabindex="-1"></a> <span class="ex">description</span> = <span class="st">&quot;A latex whitepaper project&quot;</span><span class="kw">;</span></span>
114 }; 114<span id="cb7-11"><a href="#cb7-11" aria-hidden="true" tabindex="-1"></a> <span class="kw">};</span></span>
115 rust-hello = { 115<span id="cb7-12"><a href="#cb7-12" aria-hidden="true" tabindex="-1"></a> <span class="ex">rust-hello</span> = {</span>
116 path = ./rust-hello-template; 116<span id="cb7-13"><a href="#cb7-13" aria-hidden="true" tabindex="-1"></a> <span class="ex">path</span> = ./rust-hello-template<span class="kw">;</span></span>
117 description = &quot;Simple Hello World in Rust&quot;; 117<span id="cb7-14"><a href="#cb7-14" aria-hidden="true" tabindex="-1"></a> <span class="ex">description</span> = <span class="st">&quot;Simple Hello World in Rust&quot;</span><span class="kw">;</span></span>
118 }; 118<span id="cb7-15"><a href="#cb7-15" aria-hidden="true" tabindex="-1"></a> <span class="er">}</span><span class="kw">;</span></span>
119 }; 119<span id="cb7-16"><a href="#cb7-16" aria-hidden="true" tabindex="-1"></a> <span class="er">}</span><span class="kw">;</span></span>
120 }; 120<span id="cb7-17"><a href="#cb7-17" aria-hidden="true" tabindex="-1"></a> <span class="er">}</span><span class="kw">;</span></span>
121}</code></pre> 121<span id="cb7-18"><a href="#cb7-18" aria-hidden="true" tabindex="-1"></a><span class="er">}</span></span></code></pre></div>
122<p>The <code>path</code> attribute to each template is what gets copied over when you initialize a flake. Running <code>nix flake init -t .#latex-report</code> will initialize the current directory with the contents of <code>./latex-report-template</code> (we are yet to populate these directories).</p> 122<p>The <code>path</code> attribute to each template is what gets copied over when you initialize a flake. Running <code>nix flake init -t .#latex-report</code> will initialize the current directory with the contents of <code>./latex-report-template</code> (we are yet to populate these directories).</p>
123<p>The output of <code>nix flake show</code> should be something like:</p> 123<p>The output of <code>nix flake show</code> should be something like:</p>
124<pre><code>$ nix flake show 124<div class="sourceCode" id="cb8"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> nix flake show</span>
125path:/home/np/code/nix-stuff/template-tests?narHash=sha256-{...} 125<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a><span class="ex">path:/home/np/code/nix-stuff/template-tests?narHash=sha256-{...}</span></span>
126└───templates 126<span id="cb8-3"><a href="#cb8-3" aria-hidden="true" tabindex="-1"></a><span class="ex">└───templates</span></span>
127 ├───latex-report: template: A latex whitepaper project 127<span id="cb8-4"><a href="#cb8-4" aria-hidden="true" tabindex="-1"></a> <span class="ex">├───latex-report:</span> template: A latex whitepaper project</span>
128 └───rust-hello: template: Simple Hello World in Rust</code></pre> 128<span id="cb8-5"><a href="#cb8-5" aria-hidden="true" tabindex="-1"></a> <span class="ex">└───rust-hello:</span> template: Simple Hello World in Rust</span></code></pre></div>
129<p>Populate your template directories with content, here are my template directories for example:</p> 129<p>Populate your template directories with content, here are my template directories for example:</p>
130<pre><code>$ tree mytemplates 130<div class="sourceCode" id="cb9"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> tree mytemplates</span>
131mytemplates/ 131<span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a><span class="ex">mytemplates/</span></span>
132├── flake.nix 132<span id="cb9-3"><a href="#cb9-3" aria-hidden="true" tabindex="-1"></a><span class="ex">├──</span> flake.nix</span>
133├── latex-report-template 133<span id="cb9-4"><a href="#cb9-4" aria-hidden="true" tabindex="-1"></a><span class="ex">├──</span> latex-report-template</span>
134│   ├── flake.nix 134<span id="cb9-5"><a href="#cb9-5" aria-hidden="true" tabindex="-1"></a><span class="ex">│  </span> ├── flake.nix</span>
135│   ├── makefile 135<span id="cb9-6"><a href="#cb9-6" aria-hidden="true" tabindex="-1"></a><span class="ex">│  </span> ├── makefile</span>
136│   └── src 136<span id="cb9-7"><a href="#cb9-7" aria-hidden="true" tabindex="-1"></a><span class="ex">│  </span> └── src</span>
137│   ├── meta.sty 137<span id="cb9-8"><a href="#cb9-8" aria-hidden="true" tabindex="-1"></a><span class="ex">│  </span> ├── meta.sty</span>
138│   └── report.tex 138<span id="cb9-9"><a href="#cb9-9" aria-hidden="true" tabindex="-1"></a><span class="ex">│  </span> └── report.tex</span>
139└── rust-hello-template 139<span id="cb9-10"><a href="#cb9-10" aria-hidden="true" tabindex="-1"></a><span class="ex">└──</span> rust-hello-template</span>
140 ├── Cargo.toml 140<span id="cb9-11"><a href="#cb9-11" aria-hidden="true" tabindex="-1"></a> <span class="ex">├──</span> Cargo.toml</span>
141 ├── flake.nix 141<span id="cb9-12"><a href="#cb9-12" aria-hidden="true" tabindex="-1"></a> <span class="ex">├──</span> flake.nix</span>
142 └── src 142<span id="cb9-13"><a href="#cb9-13" aria-hidden="true" tabindex="-1"></a> <span class="ex">└──</span> src</span>
143 └── main.rs</code></pre> 143<span id="cb9-14"><a href="#cb9-14" aria-hidden="true" tabindex="-1"></a> <span class="ex">└──</span> main.rs</span></code></pre></div>
144<p>And that’s it! Start using your templates with:</p> 144<p>And that’s it! Start using your templates with:</p>
145<pre><code>$ nix flake init -t ~/mytemplates#rust-hello 145<div class="sourceCode" id="cb10"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> nix flake init <span class="at">-t</span> ~/mytemplates#rust-hello</span>
146$ tree . 146<span id="cb10-2"><a href="#cb10-2" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> tree .</span>
147. 147<span id="cb10-3"><a href="#cb10-3" aria-hidden="true" tabindex="-1"></a><span class="bu">.</span></span>
148├── Cargo.toml 148<span id="cb10-4"><a href="#cb10-4" aria-hidden="true" tabindex="-1"></a><span class="ex">├──</span> Cargo.toml</span>
149├── flake.nix 149<span id="cb10-5"><a href="#cb10-5" aria-hidden="true" tabindex="-1"></a><span class="ex">├──</span> flake.nix</span>
150└── src 150<span id="cb10-6"><a href="#cb10-6" aria-hidden="true" tabindex="-1"></a><span class="ex">└──</span> src</span>
151 └── main.rs</code></pre> 151<span id="cb10-7"><a href="#cb10-7" aria-hidden="true" tabindex="-1"></a> <span class="ex">└──</span> main.rs</span></code></pre></div>
152<p>To avoid writing <code>~/mytemplates</code> each time, simply alias it to a registry:</p> 152<p>To avoid writing <code>~/mytemplates</code> each time, simply alias it to a registry:</p>
153<pre><code># alias it to `biscuits` 153<div class="sourceCode" id="cb11"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a><span class="co"># alias it to `biscuits`</span></span>
154$ nix registry add biscuits ~/mytemplates 154<span id="cb11-2"><a href="#cb11-2" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> nix registry add biscuits ~/mytemplates</span>
155 155<span id="cb11-3"><a href="#cb11-3" aria-hidden="true" tabindex="-1"></a></span>
156# you will see it listed under `user` registries 156<span id="cb11-4"><a href="#cb11-4" aria-hidden="true" tabindex="-1"></a><span class="co"># you will see it listed under `user` registries</span></span>
157$ nix registry list 157<span id="cb11-5"><a href="#cb11-5" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> nix registry list</span>
158. . . 158<span id="cb11-6"><a href="#cb11-6" aria-hidden="true" tabindex="-1"></a><span class="bu">.</span> . .</span>
159user flake:biscuits path:/home/np/template-tests 159<span id="cb11-7"><a href="#cb11-7" aria-hidden="true" tabindex="-1"></a><span class="ex">user</span> flake:biscuits path:/home/np/template-tests</span>
160. . . 160<span id="cb11-8"><a href="#cb11-8" aria-hidden="true" tabindex="-1"></a><span class="bu">.</span> . .</span>
161 161<span id="cb11-9"><a href="#cb11-9" aria-hidden="true" tabindex="-1"></a></span>
162$ nix flake init -t biscuits#latex-report</code></pre> 162<span id="cb11-10"><a href="#cb11-10" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> nix flake init <span class="at">-t</span> biscuits#latex-report</span></code></pre></div>
163<h2 id="extending-the-official-templates">Extending the official templates</h2> 163<h2 id="extending-the-official-templates">Extending the official templates</h2>
164<p>I personally, would like the <code>biscuits</code> registry to include not just my homemade templates, but also the templates from <code>NixOS/templates</code> (and maybe a couple of other repositories in the wild):</p> 164<p>I personally, would like the <code>biscuits</code> registry to include not just my homemade templates, but also the templates from <code>NixOS/templates</code> (and maybe a couple of other repositories in the wild):</p>
165<pre><code> { 165<div class="sourceCode" id="cb12"><pre class="sourceCode nix"><code class="sourceCode bash"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a> <span class="kw">{</span></span>
166 description = &quot;Pepper&#39;s flake templates&quot;; 166<span id="cb12-2"><a href="#cb12-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">description</span> = <span class="st">&quot;Pepper&#39;s flake templates&quot;</span><span class="kw">;</span></span>
167 167<span id="cb12-3"><a href="#cb12-3" aria-hidden="true" tabindex="-1"></a> </span>
168+ inputs = { 168<span id="cb12-4"><a href="#cb12-4" aria-hidden="true" tabindex="-1"></a><span class="ex">+</span> inputs = {</span>
169+ official-templates.url = github:NixOS/templates; 169<span id="cb12-5"><a href="#cb12-5" aria-hidden="true" tabindex="-1"></a><span class="ex">+</span> official-templates.url = github:NixOS/templates<span class="kw">;</span></span>
170+ other-templates.url = github:some-other/templates; 170<span id="cb12-6"><a href="#cb12-6" aria-hidden="true" tabindex="-1"></a><span class="ex">+</span> other-templates.url = github:some-other/templates<span class="kw">;</span></span>
171+ }; 171<span id="cb12-7"><a href="#cb12-7" aria-hidden="true" tabindex="-1"></a><span class="ex">+</span> }<span class="kw">;</span></span>
172 172<span id="cb12-8"><a href="#cb12-8" aria-hidden="true" tabindex="-1"></a> </span>
173 outputs = { self, official-templates, other-templates ... }: { 173<span id="cb12-9"><a href="#cb12-9" aria-hidden="true" tabindex="-1"></a> <span class="ex">outputs</span> = { self, official-templates, other-templates ... }: {</span>
174 174<span id="cb12-10"><a href="#cb12-10" aria-hidden="true" tabindex="-1"></a> </span>
175 templates = { 175<span id="cb12-11"><a href="#cb12-11" aria-hidden="true" tabindex="-1"></a> <span class="ex">templates</span> = {</span>
176 latex-report = { 176<span id="cb12-12"><a href="#cb12-12" aria-hidden="true" tabindex="-1"></a> <span class="ex">latex-report</span> = {</span>
177 path = ./latex-report-template; 177<span id="cb12-13"><a href="#cb12-13" aria-hidden="true" tabindex="-1"></a> <span class="ex">path</span> = ./latex-report-template<span class="kw">;</span></span>
178 description = &quot;A latex whitepaper project&quot;; 178<span id="cb12-14"><a href="#cb12-14" aria-hidden="true" tabindex="-1"></a> <span class="ex">description</span> = <span class="st">&quot;A latex whitepaper project&quot;</span><span class="kw">;</span></span>
179 }; 179<span id="cb12-15"><a href="#cb12-15" aria-hidden="true" tabindex="-1"></a> <span class="kw">};</span></span>
180 rust-hello = { 180<span id="cb12-16"><a href="#cb12-16" aria-hidden="true" tabindex="-1"></a> <span class="ex">rust-hello</span> = {</span>
181 path = ./rust-hello-template; 181<span id="cb12-17"><a href="#cb12-17" aria-hidden="true" tabindex="-1"></a> <span class="ex">path</span> = ./rust-hello-template<span class="kw">;</span></span>
182 description = &quot;Simple Hello World in Rust, with overloaded Rust toolchain&quot;; 182<span id="cb12-18"><a href="#cb12-18" aria-hidden="true" tabindex="-1"></a> <span class="ex">description</span> = <span class="st">&quot;Simple Hello World in Rust, with overloaded Rust toolchain&quot;</span><span class="kw">;</span></span>
183 }; 183<span id="cb12-19"><a href="#cb12-19" aria-hidden="true" tabindex="-1"></a> <span class="er">}</span><span class="kw">;</span></span>
184 } 184<span id="cb12-20"><a href="#cb12-20" aria-hidden="true" tabindex="-1"></a> <span class="er">}</span></span>
185+ // official-templates.templates 185<span id="cb12-21"><a href="#cb12-21" aria-hidden="true" tabindex="-1"></a><span class="ex">+</span> // official-templates.templates</span>
186+ // other-templates.templates; 186<span id="cb12-22"><a href="#cb12-22" aria-hidden="true" tabindex="-1"></a><span class="ex">+</span> // other-templates.templates<span class="kw">;</span></span>
187 187<span id="cb12-23"><a href="#cb12-23" aria-hidden="true" tabindex="-1"></a> </span>
188 }; 188<span id="cb12-24"><a href="#cb12-24" aria-hidden="true" tabindex="-1"></a> <span class="er">}</span><span class="kw">;</span></span>
189 }</code></pre> 189<span id="cb12-25"><a href="#cb12-25" aria-hidden="true" tabindex="-1"></a> <span class="er">}</span></span></code></pre></div>
190<p>Running <code>nix flake show biscuits</code> will now list templates from the <code>biscuits</code> registry as well as the ones from <code>NixOS/templates</code>. Ensure that the names don’t collide though.</p> 190<p>Running <code>nix flake show biscuits</code> will now list templates from the <code>biscuits</code> registry as well as the ones from <code>NixOS/templates</code>. Ensure that the names don’t collide though.</p>
191 191
192 </div> 192 </div>
diff --git a/posts/novice_nix:_flake_templates.md b/posts/novice_nix:_flake_templates.md
index 3b38b46..8e25a85 100644
--- a/posts/novice_nix:_flake_templates.md
+++ b/posts/novice_nix:_flake_templates.md
@@ -9,7 +9,7 @@ You might already be familiar with `nix flake init`, that
9drops a "default" flake expression into your current working 9drops a "default" flake expression into your current working
10directory. If you head over to the manpage: 10directory. If you head over to the manpage:
11 11
12``` 12```bash
13nix flake init --help 13nix flake init --help
14``` 14```
15 15
@@ -23,7 +23,7 @@ does this default originate from?
23Quick detour into registries! Registries are a way to alias 23Quick detour into registries! Registries are a way to alias
24popular flakes using identifiers: 24popular flakes using identifiers:
25 25
26``` 26```bash
27# list a few predefined registries 27# list a few predefined registries
28$ nix registry list 28$ nix registry list
29. . . 29. . .
@@ -47,7 +47,7 @@ $ nix flake show git+https://github.com/tweag/nickel
47You might notice a registry called `templates` aliased to 47You might notice a registry called `templates` aliased to
48`github:NixOS/templates`. Take a peek with `nix flake show`: 48`github:NixOS/templates`. Take a peek with `nix flake show`:
49 49
50``` 50```bash
51$ nix flake show templates 51$ nix flake show templates
52github:NixOS/templates/79f48a7b822f35c068c5e235da2e9fbd154cecee 52github:NixOS/templates/79f48a7b822f35c068c5e235da2e9fbd154cecee
53├───defaultTemplate: template: A very basic flake 53├───defaultTemplate: template: A very basic flake
@@ -63,7 +63,7 @@ Aha! There is a flake output called `defaultTemplate`. This
63is the template being sourced when you run `nix flake init`. 63is the template being sourced when you run `nix flake init`.
64Astute readers may conclude the following: 64Astute readers may conclude the following:
65 65
66``` 66```bash
67$ nix flake init 67$ nix flake init
68 68
69# is equivalent to 69# is equivalent to
@@ -78,7 +78,7 @@ $ nix flake init -t git+https://NixOS/templates#defaultTemplate
78 78
79Similarly, the other templates can be accessed via: 79Similarly, the other templates can be accessed via:
80 80
81``` 81```bash
82$ nix flake init -t templates#c-hello 82$ nix flake init -t templates#c-hello
83$ nix flake init -t templates#simpleContainer 83$ nix flake init -t templates#simpleContainer
84# I think you get the drift ... 84# I think you get the drift ...
@@ -96,14 +96,14 @@ Alright, so all we need to do is:
96Start off by creating a directory to store your templates in 96Start off by creating a directory to store your templates in
97(we will be converting this to a registry later): 97(we will be converting this to a registry later):
98 98
99``` 99```bash
100$ mkdir ~/mytemplates 100$ mkdir ~/mytemplates
101``` 101```
102 102
103A flake that exposes a "template" as its output looks 103A flake that exposes a "template" as its output looks
104something like this: 104something like this:
105 105
106``` 106```nix
107# inside ~/mytemplates/flake.nix 107# inside ~/mytemplates/flake.nix
108 108
109{ 109{
@@ -132,7 +132,7 @@ populate these directories).
132 132
133The output of `nix flake show` should be something like: 133The output of `nix flake show` should be something like:
134 134
135``` 135```bash
136$ nix flake show 136$ nix flake show
137path:/home/np/code/nix-stuff/template-tests?narHash=sha256-{...} 137path:/home/np/code/nix-stuff/template-tests?narHash=sha256-{...}
138└───templates 138└───templates
@@ -143,7 +143,7 @@ path:/home/np/code/nix-stuff/template-tests?narHash=sha256-{...}
143Populate your template directories with content, here are my 143Populate your template directories with content, here are my
144template directories for example: 144template directories for example:
145 145
146``` 146```bash
147$ tree mytemplates 147$ tree mytemplates
148mytemplates/ 148mytemplates/
149├── flake.nix 149├── flake.nix
@@ -162,7 +162,7 @@ mytemplates/
162 162
163And that's it! Start using your templates with: 163And that's it! Start using your templates with:
164 164
165``` 165```bash
166$ nix flake init -t ~/mytemplates#rust-hello 166$ nix flake init -t ~/mytemplates#rust-hello
167$ tree . 167$ tree .
168. 168.
@@ -175,7 +175,7 @@ $ tree .
175To avoid writing `~/mytemplates` each time, simply alias it 175To avoid writing `~/mytemplates` each time, simply alias it
176to a registry: 176to a registry:
177 177
178``` 178```bash
179# alias it to `biscuits` 179# alias it to `biscuits`
180$ nix registry add biscuits ~/mytemplates 180$ nix registry add biscuits ~/mytemplates
181 181
@@ -195,7 +195,7 @@ not just my homemade templates, but also the templates from
195`NixOS/templates` (and maybe a couple of other repositories 195`NixOS/templates` (and maybe a couple of other repositories
196in the wild): 196in the wild):
197 197
198``` 198```nix
199 { 199 {
200 description = "Pepper's flake templates"; 200 description = "Pepper's flake templates";
201 201