From 0a660c01df46652f2d29c5a14952a9ea6188adf8 Mon Sep 17 00:00:00 2001 From: John Lancaster <32917998+jsl12@users.noreply.github.com> Date: Mon, 30 Jun 2025 14:36:44 -0500 Subject: [PATCH] updates --- flake.nix | 47 ++++++++++++++++++++++++++++++++--------------- home.nix | 4 ++-- 2 files changed, 34 insertions(+), 17 deletions(-) diff --git a/flake.nix b/flake.nix index 3b7abd9..97f21c9 100644 --- a/flake.nix +++ b/flake.nix @@ -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 }; }; } diff --git a/home.nix b/home.nix index 4524c7a..cbc8822 100644 --- a/home.nix +++ b/home.nix @@ -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