nix-bash-completions icon indicating copy to clipboard operation
nix-bash-completions copied to clipboard

Fix completion with Nix 2.4+ on non-NixOS

Open bjornfor opened this issue 1 year ago • 0 comments

Nix 2.4+ stopped setting NIX_PATH in the environment and instead uses a built-in default in the C++ code (not exposed to shell processes). That means this completion codes sees $override as empty and runs NIX_PATH= nix-instantiate .... Setting NIX_PATH to an empty string means Nix won't use its default built-in value and completion breaks (assuming the completion depends on <nixpkgs> or similar search path entries).

NixOS isn't affected because there NIX_PATH is still set (by the OS, not by code from the Nix repo).

The fix is to not pass NIX_PATH unless we have a value for it. That works for both old and new Nix, on NixOS and non-NixOS.

bjornfor avatar Sep 04 '23 12:09 bjornfor