Skip to content

Commit

Permalink
doc: Explain our specialArgs
Browse files Browse the repository at this point in the history
  • Loading branch information
srid committed Oct 7, 2024
1 parent ee81dd9 commit aa83670
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions doc/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

- [Activation](activate.md)
- [Flake Templates](templates.md)
- [Module Arguments](specialArgs.md)
- [Module Outputs](outputs.md)
- [Autowiring](autowiring.md)

Expand Down
31 changes: 31 additions & 0 deletions doc/src/specialArgs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Module Arguments

Each of your NixOS, nix-darwin and home-manager modules implicitly receive a [`specialArgs`](https://nixos.asia/en/nix-modules) called `flake`.

The components of this `flake` attrset are:

| Name | Description |
| ---- | ----------- |
| `inputs` | The `inputs` of your flake; `inputs.self` referring to the flake itself |
| `config` | The flake-parts perSystem `config` |

[Here](https://github.com/srid/nixos-config/blob/a420e5f531172aef753b07a411de8e254207f5c6/modules/darwin/default.nix#L2-L5) is an example of how these can be used:

```nix
{ flake, pkgs, lib, ... }:
let
inherit (flake) config inputs;
inherit (inputs) self;
in
{
imports = [
# Reference a flake input directly from a nix-darwin module
inputs.agenix.darwinModules.default
];
# Reference an arbitrary flake-parts config
home-manager.users.${config.me.username} = { };
}
```

While the above example uses a nix-darwin module, you can do the same on NixOS or home-manager modules.

0 comments on commit aa83670

Please sign in to comment.