nix icon indicating copy to clipboard operation
nix copied to clipboard

nix develop shell incomplete PATH contents

Open corpix opened this issue 1 year ago • 1 comments

Describe the bug

Packages specified inside flake devShell packages is not listed in PATH inside nix develop shell. Is it different from nix-shell? Why?

Steps To Reproduce

Create flake.nix with this content:

{
  inputs.nixpkgs.url = "nixpkgs/nixos-unstable";
 
  outputs = { self, nixpkgs }:
    let
      arch = "x86_64-linux";
      pkgs = nixpkgs.legacyPackages.${arch}.pkgs;

      inherit (pkgs)
        writeScript
        stdenv
        mkShell
      ;

      inherit (pkgs)
        ocserv
        go
        gnumake
      ;
    in {
      devShells.${arch}.default = mkShell {
        name = "authentik-ocserv";
        packages = [
          ocserv
          go
          gnumake
        ];
      };
    };
}

Enter nix develop, run ocserv, get command not found in response:

 ~/projects/src/git.backbone/corpix/authentik-ocserv  λ  echo $SHELLcf5qqa9yfxj59ki1rb21209x7wja0m-fish-3.7.1/bin/fish
 ~/projects/src/git.backbone/corpix/authentik-ocserv  λ  nix develop                                                                                                                               
Welcome to fish, the friendly interactive shell
 ~/projects/src/git.backbone/corpix/authentik-ocserv  λ  echo $SHELL                                                                                                                               
/nix/store/31cf5qqa9yfxj59ki1rb21209x7wja0m-fish-3.7.1/bin/fish
 ~/projects/src/git.backbone/corpix/authentik-ocserv  λ  ocserv                                                                                                                                    
fish: Unknown command: ocserv
 ~/projects/src/git.backbone/corpix/authentik-ocserv  λ  nix --version
nix (Nix) 2.18.2

Expected behavior

All packages listed under packages of mkShell exists in PATH.

nix-env --version output

nix-env (Nix) 2.18.2

Priorities

Add :+1: to issues you find important.

corpix avatar Apr 27 '24 05:04 corpix

This could possibly be worked around with this ugly hack:

nix develop -c bash -ec 'exec fish'

corpix avatar Apr 27 '24 05:04 corpix

Nix develop runs bash, not fish. Perhaps your .bashrc contains a fish invocation. And I suspect it also messes with your $PATH as well. Try to start debugging from there.

xzfc avatar Jul 05 '24 19:07 xzfc

@xzfc, you are right, but everything it do is:

# If not running interactively, don't do anything
[ ! -z "$PS1" ]          || return
[ ! -z "$IN_NIX_SHELL" ] || source /etc/profile

[ ! -z "$IN_NIX_SHELL" ] || exec fish

PS1='[\u@\h \W]\$ '

But even if I remove .bashrc nothing changes. So I think the problem is in something different. I have fish shell specified as a main shell in /etc/passwd:

λ  grep /home/user /etc/passwd                                                                                      
user:x:1000:100::/home/user:/nix/store/vmzchllkdmf08786vg63kjdz5vnwh8bf-fish-3.7.1/bin/fish

So... event without mentioned .bashrc I will end up inside fish after running nix develop.

corpix avatar Jul 05 '24 21:07 corpix