Files
jsl-home/flake.nix
John Lancaster 0a660c01df updates
2025-06-30 14:36:44 -05:00

69 lines
2.0 KiB
Nix

{
description = "Home Manager configuration of john";
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 a module that contains the user option
userModule = { config, ... }: {
options.user = lib.mkOption {
type = lib.types.str;
description = "The username for the Home Manager configuration.";
default = "john";
};
};
# 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 ];
};
defaultUsername = moduleEval.config.user;
in
{
# 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
};
};
}