Open ShamrockLee opened 1 year ago
The problem is that the default nix-on-droid system does not load autocompletion files for any shell. It should be a rather simple fix in /etc/bashrc
and /etc/zshrc
adding default directories in ~/.nix-profile
to the shell init scripts.
But the more I think about it, I see a general issue of clear separation of responsibilities. To compare nix-on-droid with similar system configurations like NixOS or nix-darwin in relation with home-manager, the system configurations never read or write things in the users home directory, this is solely left for home-manager. Another interesting thing in these system configurations is that they install their final build into /run/current-system
(where the equivalent to the nix-on-droid-path
package is available in /run/current-system/sw
). This has some advantages like you have a clear separation between system installations and user specific installations. I agree that this is a rather irrelevant benefit for a single user setup but would help us maintaining a clear direction what should be scope of nix-on-droid and what is scope of home-manager.
So the change would be to load completion files for system installed packages and would then prevent redundant loading of these files once enabling home-manager which also loads them by default.
To make a long story short: Do we want to go with NixOS/nix-darwin approach of /run/current-system
instead of ~/.nix-profile
? @t184256 What do you think?
If you're asking for my opinion, it's simple: system packages are there for hardware enablement (not applicable to n-o-d), non-user services and "recovery" packages that should be enough for hammering a package manager into a usable shape. Everything else goes to user packages, or, better, home-manager. So my answer would be to enable h-m if you want any kind of bells and whistles, and then programs.bash.enableCompletion
.
I don't think this view is universally held across the Nix community, but you're right in that system packages are even less relevant for our essentially single-user install.
@t184256 Thank you for your detailed explanation.
Unfortunately, the Home Manager configuration programs.bash.enable = true;
, which should enable the default programs.bash.enableCompletion = lib.mkOptionDefault true;
, doesn't solve the issue.
I've tested it before posting this comment and it worked for me (on all-unstable channels).
~It works now after updating nix-on-droid.~
~Thanks a lot!~
Update: It's the prompt that works, not the tab completion. I'll try to upgrade nixpkgs and Home Manager to unstable also.
I eventually work around this issue using
programs.bash = {
enable = true;
bashrcExtra = ''
while IFS= read -r _completionFile; do
source "$_completionFile"
done < <(${pkgs.findutils}/bin/find "$HOME/.nix-profile/share/bash-completion/completions" -mindepth 1 -maxdepth 1 -type f,l)
unset _completionFile
'';
};
in home.nix
.
It seems that we only have tab completion for file path and commands.
Tab completions defined by individual packages, such as those for
git
, simply doesn't work.If there's a way to enable such feature, it would be great to document it.
Reproduction steps: