Adding a new home-manager module
Steps
Create the module directory and entry point:
- Path:
home/<category>/default.nix - One concern per directory (shell, git, editor, etc.)
- Path:
Choose where to import it:
home/default.nix— base dev environment (default, for anything useful on any dev machine)home/personal.nix— personal additions (only for clearly personal things)- When in doubt, use base (
home/default.nix)
Add the import:
imports = [ ./shell ./git ./tools # ...existing imports... ./<new-module> ];Write the module:
- Use
programs.<name>andhome.packagesover raw file writes — home-manager options give type checking and merging - Raw config files go in
files/<category>/and are sourced viahome.file - Module args:
{ pkgs, config, lib, ... }:— addidentityonly if needed
- Use
Platform-specific config:
- Use dedicated platform modules (
home/darwin/,home/nixos/) for growing platform-specific config - Small one-off checks with
pkgs.stdenv.isDarwinare acceptable - Platform modules are wired via
darwinHomeModules/nixosHomeModulesinflake.nix
- Use dedicated platform modules (
Test and deploy:
make check— validate flake (all platforms)make switch— apply and verify
Module template
{ pkgs, ... }:
{
programs.<name> = {
enable = true;
# configuration options here
};
}
Or for package-only modules:
{ pkgs, ... }:
{
home.packages = with pkgs; [
<package>
];
}
Conventions
- No ambiguous abbreviations:
makeDarwinnotmkDarwin(except upstream APIs likelib.mkIf) - Keep modules focused: one concern per directory
- State versions must never be changed (see CLAUDE.md)
Converted and distributed by TomeVault — claim your Tome and manage your conversions.