This commit is contained in:
John Lancaster
2025-06-30 15:19:51 -05:00
parent 8bc5d353c4
commit 3c4191b291

View File

@@ -17,8 +17,8 @@
pkgs = nixpkgs.legacyPackages.${system};
lib = pkgs.lib;
# Combined module that includes both options and configuration
combinedModule = { config, pkgs, ... }: {
# Define the module first (moved from below)
homeManagerModule = { config, pkgs, ... }: {
options.user = lib.mkOption {
type = lib.types.str;
description = "The username for the Home Manager configuration.";
@@ -29,15 +29,11 @@
# Function to create a home configuration for any user
mkHomeConfiguration = username: home-manager.lib.homeManagerConfiguration {
inherit pkgs;
modules = [
combinedModule
# Override the user option for this specific configuration
{ user = username; }
];
modules = [ homeManagerModule { user = username; } ];
};
# Default username from the module evaluation
evaluatedOptions = lib.evalModules { modules = [ combinedModule ]; };
evaluatedOptions = lib.evalModules { modules = [ homeManagerModule ]; };
userName = evaluatedOptions.config.user;
in
{
@@ -45,16 +41,9 @@
homeConfigurations.${userName} = mkHomeConfiguration userName;
# Export the function so other flakes can create configurations for any user
lib = {
mkHomeConfiguration = username: mkHomeConfiguration username;
};
lib = { mkHomeConfiguration = username: mkHomeConfiguration username; };
# Export modules for reuse in other flakes
homeManagerModules.default = combinedModule;
# Export packages if you have any custom ones
packages.${system} = {
# Add any custom packages here
};
homeManagerModules.default = homeManagerModule;
};
}