Files
jsl-home/flake.nix
John Lancaster a5d86176c6 simplified
2025-06-30 17:58:54 -05:00

49 lines
1.6 KiB
Nix

{
description = "Home Manager configuration flake for JSL";
inputs = {
# Specify the source of Home Manager and Nixpkgs.
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { nixpkgs, home-manager, ... }:
let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
lib = pkgs.lib;
# 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.";
};
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;
in
{
# Default configuration using the default username
homeConfigurations.${userName} = mkHomeConfiguration userName;
# Export the function so other flakes can create configurations for any user
lib.mkHomeConfiguration = mkHomeConfiguration;
# Export modules for reuse in other flakes
homeManagerModules.default = homeManagerModule;
};
}