Skip to content

Installing bash-completion makes bash startup slow on NixOS #32533

@hedning

Description

@hedning

Issue description

Opening up a new issue, as the last one, #22648, is closed.

bash-completion is designed to lazy load completions via __completion_loader. NixOS's generated /etc/bashrc however eagerly sources everything in $NIX_PROFILES/bash-completion/completions/* on startup (bash.nix).

This usually isn't a big problem when bash-completion isn't installed into a profile, since the big bulk of completion scripts bash-completion ships with will be correctly lazy loaded, leaving only a small amount of scripts being sourced on startup.

This however breaks when installing bash-completion as everything will be sourced on startup.

The fix

I believe the fix is simply not sourcing $NIX_PROFILES/bash-completion/completions/* via /etc/bashrc, leaving it fully up to bash-completion lazely load the scripts (it should look in its own nix store path and in ~/.nix-profile/share via $XDG_DATA_DIRS (ref).

Though I might've missed something of course so ccing @peti as he's the author of e627d30 and might know if there's any pitfalls in not sourcing on startup.

Steps to reproduce

  • enable programs.bash.enableCompletion
  • install bash-completion, either via. systemPackages or nix-env -iA nixos.bash-completion
  • start a new interactive bash shell

Technical details

  • system: "x86_64-linux"
  • host os: Linux 4.9.65, NixOS, 18.03.git.4cbbecc (Impala)
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 1.11.15
  • channels(hed): ""
  • channels(root): "nixos-17.09.1462.07ca7b64d2"
  • nixpkgs: /nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions