refactor(flake): pass assembly namespace to modules
This commit is contained in:
@@ -51,9 +51,9 @@ Use the simplest accurate word when a term is not listed.
|
||||
| forge | Git | A web service that hosts Git repositories, pull requests, issues, and code review comments. Use when the exact provider does not matter. |
|
||||
| flake | Nix | A Nix project with pinned inputs and declared outputs. Use for the repository-level build unit defined by `flake.nix`. |
|
||||
| assembly file | Nix | A Nix file under `flake/` that constructs flake outputs or arguments passed to NixOS modules. |
|
||||
| assembly function | Nix | A project function exposed under `dotfiles` because it creates modules, systems, or assembly values. |
|
||||
| assembly function | Nix | A project function exposed under `flake` because it creates modules, systems, or assembly values. |
|
||||
| library file | Nix | A Nix file that defines reusable project functions instead of a NixOS module or flake output. |
|
||||
| library function | Nix | A pure project function exposed under `dotfiles.lib`. |
|
||||
| library function | Nix | A pure project function exposed under `flake.lib`. |
|
||||
| NixOS module | Nix | A Nix file evaluated by `nixosSystem` for a NixOS configuration. |
|
||||
| overlay | Nix | A function that modifies a Nix package set by adding or replacing packages. |
|
||||
| workspace | Window management | A named or numbered group of windows in a graphical session. Some desktop environments call this a virtual desktop. |
|
||||
|
||||
16
docs/nix.md
16
docs/nix.md
@@ -10,14 +10,14 @@ Read this document with `docs/dictionary.md`.
|
||||
|
||||
Use `lib` only for the base `nixpkgs.lib` value.
|
||||
Do not use `lib` for project functions.
|
||||
Use `dotfiles.lib` for library functions passed through module arguments.
|
||||
Use `dotfiles.mk<Name>` for assembly functions passed through module arguments.
|
||||
Use `flake.lib` for library functions passed through module arguments.
|
||||
Use `flake.mk<Name>` for assembly functions passed through module arguments.
|
||||
|
||||
Avoid:
|
||||
|
||||
```nix
|
||||
{
|
||||
lib = dotfilesFunctions;
|
||||
lib = projectFunctions;
|
||||
}
|
||||
```
|
||||
|
||||
@@ -26,26 +26,26 @@ Use:
|
||||
```nix
|
||||
{
|
||||
lib = nixpkgs.lib;
|
||||
dotfiles.lib = dotfilesFunctions;
|
||||
flake.lib = projectFunctions;
|
||||
}
|
||||
```
|
||||
|
||||
### Name project function namespaces by role
|
||||
|
||||
Put pure project functions under `dotfiles.lib`.
|
||||
Put functions that create modules, systems, or assembly values under `dotfiles`.
|
||||
Put pure project functions under `flake.lib`.
|
||||
Put functions that create modules, systems, or assembly values under `flake`.
|
||||
This keeps data-only functions separate from functions that carry flake context.
|
||||
|
||||
Avoid:
|
||||
|
||||
```nix
|
||||
dotfiles.lib.mkGuest { name = "sample"; }
|
||||
flake.lib.mkGuest { name = "sample"; }
|
||||
```
|
||||
|
||||
Use:
|
||||
|
||||
```nix
|
||||
dotfiles.mkGuest { name = "sample"; }
|
||||
flake.mkGuest { name = "sample"; }
|
||||
```
|
||||
|
||||
## File Placement
|
||||
|
||||
Reference in New Issue
Block a user