2.4 KiB
2.4 KiB
Playbook: Split a Mixed Module into NixOS and Home Manager
- Name: Split a feature module into
nixos.nixandhome.nix - Purpose: Keep category-first organization while separating system concerns from Home Manager concerns for standalone homes and future Darwin usage.
- Prerequisites: Identify the feature path, current toggle shape under
my.*, and whether the module has shared helpers that should stay adjacent or move into a factory. - Inputs: Existing mixed module path, target category/name, host toggle impact, Home Manager consumers, secrets/proxy requirements.
- Steps:
- Create
modules/<category>/<name>/nixos.nixfor NixOS-only concerns such asusers.users,environment.systemPackages,services.*,programs.*, firewall rules, and SOPS-backed system resources. - Create
modules/<category>/<name>/home.nixfor Home Manager concerns such asprograms.*,xdg.*,home.file.*,services.*within Home Manager, and per-user shell aliases/config files. - Keep the toggle namespace aligned across both files so the same feature name remains recognizable. During migration, duplicate the option schema if needed rather than keeping Home Manager logic embedded in the NixOS module.
- If the feature has truly shared logic, extract it into a local helper file within the feature directory. If the same Home Manager wrapper pattern repeats across multiple features, promote that wrapper logic into
parts/core.nixhelpers instead of cloning the sameosConfigand shell-selection code. - Remove the legacy flat module only after the paired files evaluate cleanly and all references are updated.
- Create
- Validation:
modules/modules.nixdiscovers the feature’snixos.nix.config/base.nixregistersmodules/home-manager.nixinhome-manager.sharedModules, and that loader discovers the feature’shome.nix.- System-only settings no longer reference
home-manager.users.*. - Home Manager settings no longer depend on
osConfigunless that coupling is intentional and documented. - Repeated HM wrapper logic uses shared helpers from
parts/core.nixinstead of being copied between modules.
- Outputs: Split module directory, retained toggle shape, and updated docs if the feature introduces new structure patterns.
- References:
docs/constitution.md(Repository Overview, Terminology and Naming Standards, Maintenance Triggers),docs/reference/index.md(Module Directories, Auto-Import Rules)