Skip to content

Conversation

@llakala
Copy link

@llakala llakala commented Oct 11, 2025

Description

Currently, home-manager imports every single module by default. This leads to performance penalties as the number of modules increases over time (see the relevant nixpkgs issue. For power users who wish to save on eval time, I've added a minimal entrypoint. This disables almost all modules under programs/ and services/, so the user can vendor the modules they actually use manually.

To make sure this was working, I set it up in my config, and made sure that only the baseModules I specified were included.

nix-repl> options.home-manager.users.valueMeta.attrs.emanresu.configuration._module.args.baseModules
[
  /nix/store/vp1mi4bl6fhsj3g5q1z9vk5k56is84cy-source/modules/accounts/calendar.nix
  /nix/store/vp1mi4bl6fhsj3g5q1z9vk5k56is84cy-source/modules/accounts/contacts.nix
  /nix/store/vp1mi4bl6fhsj3g5q1z9vk5k56is84cy-source/modules/accounts/email.nix
  /nix/store/vp1mi4bl6fhsj3g5q1z9vk5k56is84cy-source/modules/config/home-cursor.nix
  /nix/store/vp1mi4bl6fhsj3g5q1z9vk5k56is84cy-source/modules/config/i18n.nix
  /nix/store/vp1mi4bl6fhsj3g5q1z9vk5k56is84cy-source/modules/dbus.nix
  /nix/store/vp1mi4bl6fhsj3g5q1z9vk5k56is84cy-source/modules/files.nix
  /nix/store/vp1mi4bl6fhsj3g5q1z9vk5k56is84cy-source/modules/home-environment.nix
  /nix/store/vp1mi4bl6fhsj3g5q1z9vk5k56is84cy-source/modules/i18n/input-method/default.nix
  /nix/store/vp1mi4bl6fhsj3g5q1z9vk5k56is84cy-source/modules/launchd/default.nix
  /nix/store/vp1mi4bl6fhsj3g5q1z9vk5k56is84cy-source/modules/manual.nix
  /nix/store/vp1mi4bl6fhsj3g5q1z9vk5k56is84cy-source/modules/misc/dconf.nix
  /nix/store/vp1mi4bl6fhsj3g5q1z9vk5k56is84cy-source/modules/misc/debug.nix
  /nix/store/vp1mi4bl6fhsj3g5q1z9vk5k56is84cy-source/modules/misc/editorconfig.nix
  /nix/store/vp1mi4bl6fhsj3g5q1z9vk5k56is84cy-source/modules/misc/fontconfig.nix
  /nix/store/vp1mi4bl6fhsj3g5q1z9vk5k56is84cy-source/modules/misc/gtk.nix
  /nix/store/vp1mi4bl6fhsj3g5q1z9vk5k56is84cy-source/modules/misc/lib.nix
  /nix/store/vp1mi4bl6fhsj3g5q1z9vk5k56is84cy-source/modules/misc/mozilla-messaging-hosts.nix
  /nix/store/vp1mi4bl6fhsj3g5q1z9vk5k56is84cy-source/modules/misc/news.nix
  /nix/store/vp1mi4bl6fhsj3g5q1z9vk5k56is84cy-source/modules/misc/nix-remote-build.nix
  /nix/store/vp1mi4bl6fhsj3g5q1z9vk5k56is84cy-source/modules/misc/nix.nix
  /nix/store/vp1mi4bl6fhsj3g5q1z9vk5k56is84cy-source/modules/misc/nixgl.nix
  /nix/store/vp1mi4bl6fhsj3g5q1z9vk5k56is84cy-source/modules/misc/numlock.nix
  /nix/store/vp1mi4bl6fhsj3g5q1z9vk5k56is84cy-source/modules/misc/pam.nix
  /nix/store/vp1mi4bl6fhsj3g5q1z9vk5k56is84cy-source/modules/misc/qt.nix
  /nix/store/vp1mi4bl6fhsj3g5q1z9vk5k56is84cy-source/modules/misc/qt/kconfig.nix
  /nix/store/vp1mi4bl6fhsj3g5q1z9vk5k56is84cy-source/modules/misc/shell.nix
  /nix/store/vp1mi4bl6fhsj3g5q1z9vk5k56is84cy-source/modules/misc/specialisation.nix
  /nix/store/vp1mi4bl6fhsj3g5q1z9vk5k56is84cy-source/modules/misc/submodule-support.nix
  /nix/store/vp1mi4bl6fhsj3g5q1z9vk5k56is84cy-source/modules/misc/tmpfiles.nix
  /nix/store/vp1mi4bl6fhsj3g5q1z9vk5k56is84cy-source/modules/misc/uninstall.nix
  /nix/store/vp1mi4bl6fhsj3g5q1z9vk5k56is84cy-source/modules/misc/version.nix
  /nix/store/vp1mi4bl6fhsj3g5q1z9vk5k56is84cy-source/modules/misc/vte.nix
  /nix/store/vp1mi4bl6fhsj3g5q1z9vk5k56is84cy-source/modules/misc/xdg-autostart.nix
  /nix/store/vp1mi4bl6fhsj3g5q1z9vk5k56is84cy-source/modules/misc/xdg-desktop-entries.nix
  /nix/store/vp1mi4bl6fhsj3g5q1z9vk5k56is84cy-source/modules/misc/xdg-mime-apps.nix
  /nix/store/vp1mi4bl6fhsj3g5q1z9vk5k56is84cy-source/modules/misc/xdg-mime.nix
  /nix/store/vp1mi4bl6fhsj3g5q1z9vk5k56is84cy-source/modules/misc/xdg-portal.nix
  /nix/store/vp1mi4bl6fhsj3g5q1z9vk5k56is84cy-source/modules/misc/xdg-system-dirs.nix
  /nix/store/vp1mi4bl6fhsj3g5q1z9vk5k56is84cy-source/modules/misc/xdg-terminal-exec.nix
  /nix/store/vp1mi4bl6fhsj3g5q1z9vk5k56is84cy-source/modules/misc/xdg-user-dirs.nix
  /nix/store/vp1mi4bl6fhsj3g5q1z9vk5k56is84cy-source/modules/misc/xdg.nix
  /nix/store/vp1mi4bl6fhsj3g5q1z9vk5k56is84cy-source/modules/misc/xfconf.nix
  /nix/store/vp1mi4bl6fhsj3g5q1z9vk5k56is84cy-source/modules/systemd.nix
  /nix/store/vp1mi4bl6fhsj3g5q1z9vk5k56is84cy-source/modules/targets/darwin
  /nix/store/vp1mi4bl6fhsj3g5q1z9vk5k56is84cy-source/modules/targets/generic-linux.nix
  /nix/store/vp1mi4bl6fhsj3g5q1z9vk5k56is84cy-source/modules/wayland.nix
  /nix/store/vp1mi4bl6fhsj3g5q1z9vk5k56is84cy-source/modules/xresources.nix
  /nix/store/vp1mi4bl6fhsj3g5q1z9vk5k56is84cy-source/modules/xsession.nix
  /nix/store/qkpyqhijy3vl97gvycpycb6x5ixg1b86-source/nixos/modules/misc/assertions.nix
  /nix/store/qkpyqhijy3vl97gvycpycb6x5ixg1b86-source/nixos/modules/misc/meta.nix
  /nix/store/vp1mi4bl6fhsj3g5q1z9vk5k56is84cy-source/modules/deprecations.nix
  /nix/store/vp1mi4bl6fhsj3g5q1z9vk5k56is84cy-source/modules/misc/nixpkgs-disabled.nix
  /nix/store/vp1mi4bl6fhsj3g5q1z9vk5k56is84cy-source/modules/programs/bash.nix
  /nix/store/vp1mi4bl6fhsj3g5q1z9vk5k56is84cy-source/modules/programs/autojump.nix
  /nix/store/vp1mi4bl6fhsj3g5q1z9vk5k56is84cy-source/modules/programs/zsh
  /nix/store/vp1mi4bl6fhsj3g5q1z9vk5k56is84cy-source/modules/programs/ion.nix
  /nix/store/vp1mi4bl6fhsj3g5q1z9vk5k56is84cy-source/modules/programs/nushell.nix
  /nix/store/vp1mi4bl6fhsj3g5q1z9vk5k56is84cy-source/modules/services/window-managers/i3-sway/default.nix
]

Checklist

  • Change is backwards compatible.

  • Code formatted with nix fmt or
    nix-shell -p treefmt nixfmt deadnix keep-sorted --run treefmt.

  • Code tested through nix run .#tests -- test-all or
    nix-shell --pure tests -A run.all.

  • Test cases updated/added. See example.

  • Commit messages are formatted like

    {component}: {description}
    
    {long description}
    

    See CONTRIBUTING for more information and recent commit messages for examples.

  • If this PR adds a new module

    • Added myself as module maintainer. See example.
    • Generate a news entry. See News
    • Basic tests added. See Tests
  • If this PR adds an exciting new feature or contains a breaking change.

    • Generate a news entry. See News

Copy link
Collaborator

@khaneliman khaneliman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the concept and it does seem to highlight a couple weird reference dependencies that we could code for.

./programs/zsh
./programs/ion.nix
./programs/nushell.nix
./services/window-managers/i3-sway/default.nix # Dependency of home-cursor module
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like it should be addressed with defensive logic. We should not rely on sway being present for home-cursor logic.

if minimal then
[
./programs/bash.nix
./programs/autojump.nix # Dependency of bash module
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar here, we shouldn't rely on the autojump module for bash.

@llakala
Copy link
Author

llakala commented Oct 19, 2025

Agreed on both fronts - I was just trying to get something minimal working.

The sway dependency in home-cursor is from:

  sway = {
    enable = mkEnableOption "sway config generation for {option}`home.pointerCursor`";
  };

Definitely seems like something we could just move into the sway module itself.

Meanwhile, the autojump dependency in bash is harder:

  imports = [
    (lib.mkRenamedOptionModule
      [ "programs" "bash" "enableAutojump" ]
      [
        "programs"
        "autojump"
        "enable"
      ]
    )
  ];

Renamed modules end up unfortunately creating a dependency on the new location. Maybe we could move the mkRenamedOptionModule to the autojump module itself?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants