carapace-bin icon indicating copy to clipboard operation
carapace-bin copied to clipboard

nix: flake output completion

Open Atemu opened this issue 9 months ago • 3 comments

Request

#2350 avoided adding these because fetching these was thought to be too slow (https://github.com/carapace-sh/carapace-bin/issues/2348).

This is however quite an essential feature using the nix CLI effectively.

cc @aftix

Proposed solution

Nix has built-in support for completions, couldn't those be leveraged?

NIX_GET_COMPLETIONS=2 nix build nixpkgs# instantly returns a list of completions.

Anything else?

No response

Atemu avatar May 06 '24 10:05 Atemu

Need to have a look at it, but should have the same issue. You probably get instant results because you have already invoked it before.

The problem is the first invocation. E.g. there is one nix command that triggers the channel download, which is like ~15mb as far as i remember. Anything above 100ms starts to feel slow in shell completion. Couple of seconds are fine when it is apparrent to the user that remote data needs to be fetched. But things like this simply block for quite a long time without any feedback. So it has to be a task detached from the shell completion. Nothing too complicated, but needs a generic concept as other commands have this issue as well.

rsteube avatar May 06 '24 11:05 rsteube

Indeed it has that issue. I pin my nixpkgs, so it is almost always cached for me.

It's honestly not that huge of an issue though IMHO. Better wait a few seconds every so often than to have no completion at all. It's the same with regular upstream bash completions, so, while obviously not ideal, this is intended behaviour.

Atemu avatar May 06 '24 11:05 Atemu

With flakes, the time to generate the completions are much faster than using channels, but the first time running the completions command on a flake still takes ~2ish seconds to generate, even if used on a flake located in a local directory.

aftix avatar May 06 '24 21:05 aftix