Interactive devShells in Nix Flakes, 24.11 Edition

After updating to nixpkgs 24.11, I began to notice an issue on both NixOS, and on a non-NixOS nix system. This is the symptom: starting a dev shell then starting a new shell within it results in a bad bash:

[bbarker@nixos:~/Downloads/tmp_flake]$ nix develop
warning: unknown experimental feature 'nix-develop'
warning: Git tree '/home/bbarker/Downloads/tmp_flake' is dirty
warning: creating lock file '/home/bbarker/Downloads/tmp_flake/flake.lock':
• Added input 'flake-utils':
    'github:numtide/flake-utils/11707dc2f618dd54ca8739b309ec4fc024de578b?narHash=sha256-l0KFg5HjrsfsO/JpG%2Br7fRrqm12kzFHyUHqHCVpMMbI%3D' (2024-11-13)
• Added input 'flake-utils/systems':
    'github:nix-systems/default/da67096a3b9bf56a91d16901293e51ba5b49a27e?narHash=sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768%3D' (2023-04-09)
• Added input 'nixpkgs':
    'github:NixOS/nixpkgs/635e887b48521e912a516625eee7df6cf0eba9c1?narHash=sha256-vH5mXxEvZeoGNkqKoCluhTGfoeXCZ1seYhC2pbMN0sg%3D' (2025-01-12)
warning: Git tree '/home/bbarker/Downloads/tmp_flake' is dirty

[bbarker@nixos:~/Downloads/tmp_flake]$ bash
bash: shopt: progcomp: invalid shell option name

\[\][\[\]bbarker@nixos:~/Downloads/tmp_flake]$\[\]

Here is one such flake:

{
  description = "A minimal flake";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
    flake-utils.url = "github:numtide/flake-utils";
  };

  outputs = { self, nixpkgs, flake-utils }:
    flake-utils.lib.eachDefaultSystem (system:
      let
        pkgs = nixpkgs.legacyPackages.${system};
      in
      {
        devShells.default = pkgs.mkShell {
          packages = with pkgs; [
            # Add your development dependencies here
          ];
        };
      }
    );
}

Here's the shell being started:

which bash
/nix/store/gwgqdl0242ymlikq9s9s62gkp5cvyal3-bash-5.2p37/bin/bash

I've noticed that starting the interactive shell installed by home manager will result in a working shell. Logging into a vtty in linux (a new login shell) also seems to be finding the interactive bash installed by home manager.

So why is the dev shell not doing this?

Reverting the dev shell to 24.05 didn't help, nor did advancing to nixos-unstable. I had switched home-manager to specify the usage of interactive bash, and assuming I did that correctly, that didn't help either. To my mind it must be related to how the dev shell itself is setting paths in 24.11, which is presumably controlled by the version of nix installed on the system.

The following fix seems to work, with the caveat that sometimes* one still has to run bash from the dev shell:

shellHook = ''
  export PATH="${pkgs.bashInteractive}/bin:$PATH"
'';

While this isn't terribly hacky, I wouldn't mind having a deeper understanding of why this change occurred. Feel free to add any findings here using hypothes.is or contact me.

* Nothing is better than a "sometimes" when debugging; it seems to occur in more complex flakes where a child shell of the dev shell is started; the dev shell itself doesn't seem to exhibit the issue, as mentioned above.