diff --git a/flake.nix b/flake.nix index 96f7c3f..535b438 100644 --- a/flake.nix +++ b/flake.nix @@ -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; }; }