nix-playgraound/notes/021-home-manager-modules.md

44 lines
1.0 KiB
Markdown
Raw Permalink Normal View History

# Home Manager Modules
2026-04-24 12:46:19 +02:00
This note covers `18-home-manager-module/`, which defines a small reusable Home Manager module in `module.nix` and verifies it by evaluating a
throwaway Home Manager configuration.
---
## 1. What This Example Mirrors
This example is the Home Manager counterpart to `04-nixos-module/`.
It has the same shape:
- one option namespace,
- one configuration effect, and
- one check that evaluates a temporary configuration.
2026-04-24 12:46:19 +02:00
The important difference is the target system. Home Manager modules work on `home.*` options rather than `services.*`, `environment.*`, or other NixOS
module options.
---
## 2. Why the Check Reads a Config Value
2026-04-24 12:46:19 +02:00
The flake does not need to switch a real Home Manager configuration. It only needs to prove that the module evaluates and contributes the expected
value.
That is why the check reads:
- `testConfig.config.home.file."welcome.txt".text`
instead of trying to activate a real profile.
---
## 3. Commands to Try
```bash
cd 18-home-manager-module
nix flake show
nix flake check
```