feat(mksystem): consumer-friendly home-manager resolution

mkSystem resolved the user's home config only from this repo's
users/<user>/, so an external consumer's user got no home-manager setup.
Add a `home` param (a path) and resolve in priority order: caller `home`
-> internal users/<user>/home-manager.nix -> OmniXY's home.nix. Internal
hosts keep their shims (unchanged); consumers now get a working home by
default. Unblocks the consumer template.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Padreug 2026-06-28 10:34:42 +02:00
commit 08c2a1a46c

View file

@ -56,6 +56,10 @@ name:
user,
devEnv ? false,
modules ? [ ],
# Home-manager config for `user`, as a PATH. External consumers pass
# their own (e.g. `home = ./home.nix`). When null, fall back to this
# repo's users/<user>/home-manager.nix, then to Omnixient's home.nix.
home ? null,
# Extra args merged into the system-level specialArgs. Used by hosts
# whose configuration.nix expects values beyond the defaults (e.g.
# omni's configuration.nix takes `settings` from settings.nix).
@ -84,10 +88,21 @@ let
throw "mksystem: no host config for '${name}' add hosts/${name}/ or pass one via `modules` (looked at ${toString hostDir} and ${toString hostFile})";
userNixosConfig = ../users/${user}/nixos.nix;
userHMConfig = ../users/${user}/home-manager.nix;
hasUserNixosConfig = builtins.pathExists userNixosConfig;
hasUserHMConfig = builtins.pathExists userHMConfig;
# Home-manager config for `user`, resolved in priority order so both
# internal hosts and external consumers get a working home:
# 1. caller-supplied `home` (consumer override), else
# 2. this repo's users/<user>/home-manager.nix (internal hosts), else
# 3. Omnixient's default home.nix (consumer whose user isn't in this tree).
internalUserHM = ../users/${user}/home-manager.nix;
userHMConfig =
if home != null then
home
else if builtins.pathExists internalUserHM then
internalUserHM
else
../home.nix;
in
nixpkgs.lib.nixosSystem {
@ -149,9 +164,11 @@ nixpkgs.lib.nixosSystem {
# bootstrap.
../modules/home-manager-bootstrap.nix
]
++ nixpkgs.lib.optional hasUserHMConfig {
home-manager.users.${user} = import userHMConfig;
}
++ [
# Home config for `user` — always wired now that userHMConfig always
# resolves (caller `home`, internal shim, or Omnixient's home.nix).
{ home-manager.users.${user} = import userHMConfig; }
]
# dev-env is opt-in.
++ nixpkgs.lib.optional devEnv ../modules/dev-env
# Caller-supplied extras.