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

1.0 KiB

Home Manager Modules

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.

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

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

cd 18-home-manager-module

nix flake show
nix flake check