From 08c2a1a46ca1c9dc83dd525823d840bacaac0320 Mon Sep 17 00:00:00 2001 From: Padreug Date: Sun, 28 Jun 2026 10:34:42 +0200 Subject: [PATCH] feat(mksystem): consumer-friendly home-manager resolution mkSystem resolved the user's home config only from this repo's users//, 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//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 --- lib/mksystem.nix | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/lib/mksystem.nix b/lib/mksystem.nix index 851e365..477d4c4 100644 --- a/lib/mksystem.nix +++ b/lib/mksystem.nix @@ -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//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//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.