From dd0ff1e6acca4ae788da0e64b78fb7a421ebf261 Mon Sep 17 00:00:00 2001 From: Mohammad Rafiq Date: Thu, 3 Jul 2025 21:14:30 +0800 Subject: [PATCH] feat(docs): add cheatsheet --- README.md | 1 + docs/cheatsheet.md | 1 + modules/docs/cheatsheet.nix | 17 +++++++++++++++++ 3 files changed, 19 insertions(+) create mode 100644 docs/cheatsheet.md create mode 100644 modules/docs/cheatsheet.nix diff --git a/README.md b/README.md index 65f57a6..1340e7c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ This flake uses the [files flake-parts module](https://flake.parts/options/files.html) to generate documentation. The list of generated files are: +- [docs/cheatsheet.md](docs/cheatsheet.md) - [README.md](README.md) The option `text. supports either a string or a submodule with attributes order and parts. The parts attribute can either be a string, which will get concatenated in the order laid out in `text..order`, or can itself have the attributes order and parts, in which case it will be evaluated recursively. \ No newline at end of file diff --git a/docs/cheatsheet.md b/docs/cheatsheet.md new file mode 100644 index 0000000..7d0781c --- /dev/null +++ b/docs/cheatsheet.md @@ -0,0 +1 @@ +`__curPos.file` will give the full evaluated path of the nix file it is called in. See [this issue](https://github.com/NixOS/nix/issues/5897#issuecomment-1012165198) for more information. \ No newline at end of file diff --git a/modules/docs/cheatsheet.nix b/modules/docs/cheatsheet.nix new file mode 100644 index 0000000..aba7f33 --- /dev/null +++ b/modules/docs/cheatsheet.nix @@ -0,0 +1,17 @@ +{ lib, config, ... }: +let + inherit (lib) concatStringsSep singleton; +in +{ + text.cheatsheet = concatStringsSep "\n" [ + "`__curPos.file` will give the full evaluated path of the nix file it is called in. See [this issue](https://github.com/NixOS/nix/issues/5897#issuecomment-1012165198) for more information." + ]; + perSystem = + { pkgs, ... }: + { + files.files = singleton { + path_ = "docs/cheatsheet.md"; + drv = pkgs.writeText "cheatsheet.md" config.text.cheatsheet; + }; + }; +}