docs: write initial documentation

This commit is contained in:
technofab 2025-04-28 13:06:28 +02:00
parent 94aa02b9e3
commit b75456810f
6 changed files with 274 additions and 4 deletions

62
docs/usage.md Normal file
View file

@ -0,0 +1,62 @@
# Using Nixlets
## Fetching
You can fetch Nixlets you uploaded somewhere [earlier](./packaging.md) using an URL to the tarball and the sha256 hash:
```nix
nixlet-lib.fetchNixlet "<URL>" "<sha>"
```
For the GitLab Package Registry there is a helper function:
```nix
nixlet-lib.fetchNixletFromGitlab {
project = "<org>/<project>"; # eg "TECHNOFAB/nixlets"
name = "<nixlet>";
version = "<version>";
sha256 = "<sha>";
}
```
## Metadata
A Nixlet's metadata can easily be accessed:
```nix
(<some nixlet>).description # version, name, etc.
```
## Rendering
Rendering a Nixlet will produce a YAML file which contains all the resources.
```nix
(<some nixlet>).render {
inherit system;
# values = {};
# project = "";
# overrides = ({...}: {});
}
```
Parameters:
- `system`: needed for Kubenix to work.
- `values`: values to pass to the Nixlet, gets validated by the Nixlets options
- `project`: project to use, makes it possible to use the same Nixlet multiple
times without conflicts
- `overrides`: custom module which can override configuration
## Just evaluating
Instead of directly rendering a Nixlet it's also possible to just evaluate it
and access all kinds of data inside it.
```nix
(<some nixlet>).eval {
# see above
}
```
It accepts the same parameters as `render`.