This commit is contained in:
John Lancaster
2025-06-30 14:36:44 -05:00
parent 83e2f6c0f8
commit 0a660c01df
2 changed files with 34 additions and 17 deletions

View File

@@ -26,26 +26,43 @@
};
};
# Evaluate the module to get the config
# Function to create a home configuration for any user
mkHomeConfiguration = username: home-manager.lib.homeManagerConfiguration {
inherit pkgs;
modules = [
./home.nix
userModule
# Override the user option for this specific configuration
{ user = username; }
];
};
# Default username from the module evaluation
moduleEval = lib.evalModules {
modules = [ userModule ];
};
username = moduleEval.config.user;
defaultUsername = moduleEval.config.user;
in
{
homeConfigurations.${username} = home-manager.lib.homeManagerConfiguration {
inherit pkgs;
# Specify your home configuration modules here, for example,
# the path to your home.nix.
modules = [
./home.nix
userModule # Include the user module in Home Manager modules too
];
# Optionally use extraSpecialArgs
# to pass through arguments to home.nix
# Default configuration using the default username
homeConfigurations.${defaultUsername} = mkHomeConfiguration defaultUsername;
# Export the function so other flakes can create configurations for any user
lib = {
mkHomeConfiguration = mkHomeConfiguration;
mkHomeConfigurationForUser = username: mkHomeConfiguration username;
};
# Export modules for reuse in other flakes
homeManagerModules = {
default = ./home.nix;
john-config = ./home.nix;
user-module = userModule;
};
# Export packages if you have any custom ones
packages.${system} = {
# Add any custom packages here
};
};
}

View File

@@ -3,8 +3,8 @@
{
# Home Manager needs a bit of information about you and the paths it should
# manage.
home.username = "john";
home.homeDirectory = "/home/john";
home.username = config.user;
home.homeDirectory = "/home/${config.user}";
# This value determines the Home Manager release that your configuration is
# compatible with. This helps avoid breakage when a new Home Manager release