From 5acd4c77a0ad5499fbd558e8f93f461f84ab26d1 Mon Sep 17 00:00:00 2001 From: Akshay Date: Wed, 6 Oct 2021 08:03:01 +0530 Subject: add missing syntax highlighting --- posts/novice_nix:_flake_templates.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'posts') 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 drops a "default" flake expression into your current working directory. If you head over to the manpage: -``` +```bash nix flake init --help ``` @@ -23,7 +23,7 @@ does this default originate from? Quick detour into registries! Registries are a way to alias popular flakes using identifiers: -``` +```bash # list a few predefined registries $ nix registry list . . . @@ -47,7 +47,7 @@ $ nix flake show git+https://github.com/tweag/nickel You might notice a registry called `templates` aliased to `github:NixOS/templates`. Take a peek with `nix flake show`: -``` +```bash $ nix flake show templates github:NixOS/templates/79f48a7b822f35c068c5e235da2e9fbd154cecee ├───defaultTemplate: template: A very basic flake @@ -63,7 +63,7 @@ Aha! There is a flake output called `defaultTemplate`. This is the template being sourced when you run `nix flake init`. Astute readers may conclude the following: -``` +```bash $ nix flake init # is equivalent to @@ -78,7 +78,7 @@ $ nix flake init -t git+https://NixOS/templates#defaultTemplate Similarly, the other templates can be accessed via: -``` +```bash $ nix flake init -t templates#c-hello $ nix flake init -t templates#simpleContainer # I think you get the drift ... @@ -96,14 +96,14 @@ Alright, so all we need to do is: Start off by creating a directory to store your templates in (we will be converting this to a registry later): -``` +```bash $ mkdir ~/mytemplates ``` A flake that exposes a "template" as its output looks something like this: -``` +```nix # inside ~/mytemplates/flake.nix { @@ -132,7 +132,7 @@ populate these directories). The output of `nix flake show` should be something like: -``` +```bash $ nix flake show path:/home/np/code/nix-stuff/template-tests?narHash=sha256-{...} └───templates @@ -143,7 +143,7 @@ path:/home/np/code/nix-stuff/template-tests?narHash=sha256-{...} Populate your template directories with content, here are my template directories for example: -``` +```bash $ tree mytemplates mytemplates/ ├── flake.nix @@ -162,7 +162,7 @@ mytemplates/ And that's it! Start using your templates with: -``` +```bash $ nix flake init -t ~/mytemplates#rust-hello $ tree . . @@ -175,7 +175,7 @@ $ tree . To avoid writing `~/mytemplates` each time, simply alias it to a registry: -``` +```bash # alias it to `biscuits` $ nix registry add biscuits ~/mytemplates @@ -195,7 +195,7 @@ not just my homemade templates, but also the templates from `NixOS/templates` (and maybe a couple of other repositories in the wild): -``` +```nix { description = "Pepper's flake templates"; -- cgit v1.2.3