61 lines
1.8 KiB
Nix
61 lines
1.8 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;
|
|
|
|
# Combined module that includes both options and configuration
|
|
combinedModule = { 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 = [
|
|
combinedModule
|
|
# Override the user option for this specific configuration
|
|
{ user = username; }
|
|
];
|
|
};
|
|
|
|
# Default username from the module evaluation
|
|
evaluatedOptions = lib.evalModules { modules = [ combinedModule ]; };
|
|
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 = 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
|
|
};
|
|
};
|
|
}
|