Home Manager configuration

This module sets up home-manager to set up dotfiles for my primary user, mjm.

{
  inputs,
  config,
  localModulesPath,
  lib,
  ...
}:
let
  cfg = config.mjm.home-manager;
in
{
  options.mjm.home-manager = {
    enable = lib.mkEnableOption "Home Manager for mjm" // {
      default = true;
    };
  };

  config = lib.mkIf cfg.enable {
    <<config>>
  };
}

home-manager setup is enabled by default on my machines, but it is gated behind an option to avoid setting it up on microVMs. Servers will have less things enabled in home-manager, but it's still nice to have some things set up there. I use the NixOS/nix-darwin module for this, so home-manager activation is part of the overall system setup.

home-manager.useUserPackages = true;
home-manager.useGlobalPkgs = true;
home-manager.extraSpecialArgs = { inherit inputs; };
home-manager.backupFileExtension = "bak";

I personally think that useUserPackages and useGlobalPkgs should both be enabled by default when using home-manager as part of system configuration. The former installs packages from home-manager via the users.users..packages option. The latter makes the pkgs argument for home-manager modules be the same as the NixOS system's, so you don't duplicate pkgs for no good reason. That does force any necessary nixpkgs configuration to happen on the NixOS side, but I find that a small price to pay.

home-manager.users.mjm = {
  imports =
    let
      machineSpecificConfig = ../../hosts/${config.networking.hostName}/home.nix;
    in
    [ "${localModulesPath}/home-manager" ]
    ++ lib.optional (lib.pathExists machineSpecificConfig) machineSpecificConfig;
};

This actually sets up the configuration for home-manager for the mjm user on the machine. Any machine will import "modules/home-manager", which pulls in all the default behavior as well as options to enable extra things. For machine-specific tweaks, there's some "magic" to look for a home.nix file in the directory corresponding to the host's configuration. If it exists, it will be imported as a home-manager module as well.

Proxy Information
Original URL
gemini://midna.dev/homelab/modules/common/home-manager/
Status Code
Success (20)
Meta
text/gemini;lang=en-US
Capsule Response Time
7.592695 milliseconds
Gemini-to-HTML Time
0.072346 milliseconds

This content has been proxied by September (UNKNO).