Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nix: flake output completion #2374

Open
Atemu opened this issue May 6, 2024 · 3 comments
Open

nix: flake output completion #2374

Atemu opened this issue May 6, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@Atemu
Copy link

Atemu commented May 6, 2024

Request

#2350 avoided adding these because fetching these was thought to be too slow (#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 Atemu added the enhancement New feature or request label May 6, 2024
@rsteube
Copy link
Member

rsteube commented May 6, 2024

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.

@Atemu
Copy link
Author

Atemu commented May 6, 2024

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.

@aftix
Copy link
Contributor

aftix commented May 6, 2024

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.

Atemu added a commit to Atemu/dotfiles that referenced this issue May 17, 2024
It currently cannot complete flake outputs but carapace can be configured to
bridge bash completions for certain commands.

See carapace-sh/carapace-bin#2374
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants