This commit is contained in:
John Lancaster
2025-06-30 18:27:45 -05:00
parent a5d86176c6
commit a048152eb0
3 changed files with 97 additions and 8 deletions

View File

@@ -16,21 +16,22 @@
pkgs = nixpkgs.legacyPackages.${system};
lib = pkgs.lib;
# Define the module first (moved from below)
# Defined up separately up here so that it can be evaluated by itself to determine the username
homeManagerModule = { config, pkgs, ... }: {
options.user = lib.mkOption {
type = lib.types.str;
description = "The username for the Home Manager configuration.";
};
options.profile = lib.mkOption {
type = lib.types.enum [ "personal" "work" ];
default = "personal";
description = "Profile type for the Home Manager configuration.";
};
imports = [ ./home.nix ];
};
# Function to create a home configuration for any user
mkHomeConfiguration = username: home-manager.lib.homeManagerConfiguration {
inherit pkgs;
modules = [ homeManagerModule { user = username; } ];
};
# Default username from the module evaluation
evaluatedOptions = lib.evalModules { modules = [ homeManagerModule ]; };
userName = evaluatedOptions.config.user;
@@ -40,7 +41,12 @@
homeConfigurations.${userName} = mkHomeConfiguration userName;
# Export the function so other flakes can create configurations for any user
lib.mkHomeConfiguration = mkHomeConfiguration;
lib.mkHomeConfiguration = username: home-manager.lib.homeManagerConfiguration {
inherit pkgs;
modules = [
homeManagerModule { user = username; }
];
};
# Export modules for reuse in other flakes
homeManagerModules.default = homeManagerModule;