Skip to content

Bash completion in nix-shell -p (also solving support for strictDeps by default) #4254

@roberth

Description

@roberth

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

nix-shell doesn't currently provide bash completion for new commands that provide their own completion scripts.
NixOS/nixpkgs#103501 aims to change that, but can't support completions in nix-shell -p because that command adds to the wrong attribute, buildInputs instead of nativeBuildInputs.

Describe the solution you'd like

nix-shell should set nativeBuildInputs (one way or another).

This aligns with having strictDeps by default (which is not a requirement though). StrictDeps enforces desirable properties like outputs not retaining references to build tools. It also prevents mistakes that break cross-compilation.

We can pick from these designs or think of something better.

principled scheme

-p sets both and emits a warning
--tool adds to nativeBuildInputs
--input adds to buildInputs

minimal scheme

-p sets nativeBuildInputs
--input adds to buildInputs

With the minimal scheme we don't have to update all documentation to change -ps to --tools, but it will silently break some nix-shell invocations.

compatible scheme

Like the principled scheme but without the warning. Does nothing to help towards strictDeps.

Describe alternatives you've considered

Also add buildInputs to XDG_DATA_DIRS, but this "non-strictDeps" behavior is risky, potentially affecting any build in Nixpkgs.

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions