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

bash autocompletion in nix shell (nix command) #4453

Open
roberth opened this issue Jan 15, 2021 · 7 comments
Open

bash autocompletion in nix shell (nix command) #4453

roberth opened this issue Jan 15, 2021 · 7 comments
Labels
new-cli Relating to the "nix" command nix-shell nix-shell, nix develop, nix print-dev-env, etc

Comments

@roberth
Copy link
Member

roberth commented Jan 15, 2021

Is your feature request related to a problem? Please describe.

It's frustrating when autocompletion doesn't work in a shell.

Describe the solution you'd like

Simple option: add entries to XDG_DATA_DIRS.

Complicated option: make nix shell use stdenv, which can take care of this logic, at the cost of a Nixpkgs dependency.

Describe alternatives you've considered

Write GUIs for everything that shouldn't have a GUI.

Additional context

Completions are available for derivation-based shells since NixOS/nixpkgs#103501

nix-shell also needs adjustment, see #4452

@roberth roberth changed the title bash autocompletion for nix shell (nix command) bash autocompletion in nix shell (nix command) Feb 17, 2021
@roberth
Copy link
Member Author

roberth commented Jul 7, 2021

Another way to make this work is by using passthru to inform how a package should added to the environment variables, generically. See also env noun suggestion

This is similar to what the stdenv machinery does in a package build, but simplified and specifically for use outside a package build.
Perhaps this should be incorporated into the "app" concept or vice versa.

@roberth
Copy link
Member Author

roberth commented Jul 7, 2021

Basically what I'm suggesting is to treat "environment variables" as a serious deployment target, where a package can tell Nix exactly what to do, or rely on the default (PATH + possibly XDG_DATA_DIRS)

Something like

passthru.useViaEnvironment = {
  PATH = "${self.outPath}/bin:${commonlyUsedRuntimeDep}/bin";
  XDG_DATA_DIRS = "${self.outPath}/share/foo";
  shellHook = "echo To initialize the foo package config, run foo init";
}

just to illustrate the concept.

I'm assuming NixOS/nixpkgs#119942 for simplicity on the Nix side of this interface. The self-referential nature of this feature can be worked around with placeholders, but I would prefer to exploit the existing language instead.

How the exactly the environment variables should be merged isn't obvious. Nix could hardcode some of them. Nixpkgs doesn't know how to do it yet either NixOS/nixpkgs#122244.

@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/confusion-about-bash-completions-flake-related/14579/16

@SuperSandro2000
Copy link
Member

Is this similar to nix-community/lorri#61 ?

@roberth
Copy link
Member Author

roberth commented Aug 21, 2021

@SuperSandro2000 yes, it's all necessary to make completions work beyond simple nix-shell + stdenv (NixOS/nixpkgs#103501)

@roberth
Copy link
Member Author

roberth commented Sep 25, 2021

nix shell (or whatever it will be called #4715) could solve this by depending on NixOS/nixpkgs#132617, allowing a small amount of behavior to be added, without burdening Nix itself with it.

@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/interactive-bash-with-nix-develop-flake/15486/4

@stale stale bot added the stale label Aug 13, 2022
@stale stale bot removed the stale label Dec 5, 2022
@fricklerhandwerk fricklerhandwerk added new-cli Relating to the "nix" command nix-shell nix-shell, nix develop, nix print-dev-env, etc labels Feb 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new-cli Relating to the "nix" command nix-shell nix-shell, nix develop, nix print-dev-env, etc
Projects
None yet
Development

No branches or pull requests

4 participants