Hi!
I have the following setup: WSL1+Ubuntu 18 with “nix-as-package-manager” and home-manager
for configuration.
There are git completion scripts provided by distro (somewhere in /usr/share/bash_completions
) and they are sourced in may .bashrc
. The .profile
sources both .bashrc
and . "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh"
(as advised in HM’s readme).
Git autocomplete works if home-manager
does not handle git
If, however, when I enable git
(programs.git={enable=true;};
) in home-manager
, I get autocomplete only for aliases defined in home.nix
; if there are no aliases, there is no git autocomplete at all.
What would be the correct way to both manage git configuration via home-manager
and have decent git autocomplete (with commands and --options
)?
Cheers!
(I originally posted this question on r/NixOs, by the way)
the hm-session-vars.sh
only really sets up XDG:
# Only source this once.
if [ -n "$__HM_SESS_VARS_SOURCED" ]; then return; fi
export __HM_SESS_VARS_SOURCED=1
export JQ_COLORS="1;30:0;39:0;39:0;39:0;32:1;39:1;39"
export XDG_CACHE_HOME="/home/jon//.cache"
export XDG_CONFIG_HOME="/home/jon//.config"
export XDG_DATA_HOME="/home/jon//.local/share"
what I think it happening is that your shell isn’t aware that it should source share/bash_completion/
on each package.
home-manager installs the completions at ~/.nix-profile/share/bash-completion/completions/
on my system. I’m sure you could source each file to enable completion.
Generally this isn’t needed as bash controlled by home-manager/nixos usually does this for you.
3 Likes
@jonringer My hm-session-vars.sh
does not do anything related to XDG:
if [ -n "$__HM_SESS_VARS_SOURCED" ]; then return; fi
export __HM_SESS_VARS_SOURCED=1
export EDITOR="vim"
export TMUX_TMPDIR="${XDG_RUNTIME_DIR:-"/run/user/\$(id -u)"}"
In my case, as per kind advice by u/rycee@reddit, adding
export XDG_DATA_DIRS=$HOME/.nix-profile/share:$XDG_DATA_DIRS
in my .profile
solved the problem.
However, my knowledge of *nix configuration is quite limited, so maybe other solutions exists or there are better ways to configure nix+hm rather than my current setup.