make flake template welcomeText markdown

This commit is contained in:
Taeer Bar-Yam 2022-02-17 13:59:32 -05:00
parent f3a2940e70
commit f56dd3a36b
2 changed files with 13 additions and 6 deletions

View file

@ -37,8 +37,8 @@ A flake can declare templates through its `templates` and
* `path`: The path of the directory to be copied. * `path`: The path of the directory to be copied.
* `welcomeText`: A block of text to display when a user initializes a new flake * `welcomeText`: A block of markdown text to display when a user initializes a
based on this template. new flake based on this template.
Here is an example: Here is an example:
@ -50,8 +50,14 @@ outputs = { self }: {
path = ./rust; path = ./rust;
description = "A simple Rust/Cargo project"; description = "A simple Rust/Cargo project";
welcomeText = '' welcomeText = ''
You've created a simple Rust/Cargo template. # Simple Rust/Cargo Template
Visit https://www.rust-lang.org/ for more info. ## Intended usage
The intended usage of this flake is...
## More info
- [Rust language](https://www.rust-lang.org/)
- [Rust on the NixOS Wiki](https://nixos.wiki/wiki/Rust)
- ...
''; '';
}; };

View file

@ -13,6 +13,7 @@
#include "registry.hh" #include "registry.hh"
#include "json.hh" #include "json.hh"
#include "eval-cache.hh" #include "eval-cache.hh"
#include "markdown.hh"
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
#include <queue> #include <queue>
@ -741,8 +742,8 @@ struct CmdFlakeInitCommon : virtual Args, EvalCommand
} }
auto welcomeText = cursor->maybeGetAttr("welcomeText"); auto welcomeText = cursor->maybeGetAttr("welcomeText");
if (welcomeText) { if (welcomeText) {
notice("\n----------\n"); notice("\n");
notice(welcomeText->getString()); notice(renderMarkdownToTerminal(welcomeText->getString()));
} }
} }
}; };