Consider the following bare Nix shell environment. shell.nix
:
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell { }
And this flake.nix
:
{
outputs = inputs@{ self, nixpkgs, ... }:
let
pkgs = import nixpkgs { system = "x86_64-linux"; };
in
{
devShell."x86_64-linux" = import ./shell.nix { inherit pkgs; };
};
}
The nix-shell
will yield an interactive Bash:
$ nix-shell
[nix-shell:/tmp/x]$ echo $SHELL
/nix/store/lz9s7v9xxkr3jf4wlah9vw1knmic2nda-bash-interactive-5.1-p8/bin/bash
while nix develop
does not:
$ nix develop
$ echo $SHELL
/nix/store/wadmyilr414n7bimxysbny876i2vlm5r-bash-5.1-p8/bin/bash
This leads to issues when launching applications like Vim and Visual Studio Code, which launch integrated terminals that will be ‘dumb’. This means the arrow keys and DEL will not behave like expected… This issue refers to when nix-shell
also had this problem, it seems: Vim in nix-shell starts non-interactive bash on :shell and :terminal · Issue #2034 · NixOS/nix · GitHub
Is there a way to make nix develop
behave like nix-shell
?
(And as a side question: Is it possible for nix develop
to show a prompt similar to nix-shell
to be able to distinguish we’re in a sub shell?)
[Update: does not work.] A solution that I came up with is to add the following shellHook
to mkShell
for the Flake:
shellHook = ''
SHELL=${pkgs.bashInteractive}/bin/bash
'';
But, I am not very experienced with Nix to know if this is the right direction. Or perhaps I am solving the wrong problem here.