Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nix-shell reevaluating shellHook from shell configured by nix-shell some_file.nix for next new nix-shell -p #10679

Closed
SeaOfCrystalGreens opened this issue May 11, 2024 · 1 comment
Labels

Comments

@SeaOfCrystalGreens
Copy link

nix-shell seems to rerun shellHook from

pkgs.mkShell {
  buildInputs = with pkgs; [ nodejs_21 ];
  shellHook = ''
    echo n2.nix
  '';
}

for most recently used file.nix after

> nix-shell file.nix

when invoking nix-shell with --package parameter in any directory.
When invoking only nix-shell and ommiting --package

error: getting status of '/.../default.nix': No such file or directory

is emited.

Steps To Reproduce

  1. Create directory structure test/shells
  2. Crate file new_shell.nix inside shells
  3. Content of file new_shell.nix
{ pkgs ? import <nixpkgs> {} }:
let
  
in
pkgs.mkShell {
  buildInputs = with pkgs; [ ];
  shellHook = ''
    echo new_shell.nix
  '';
}
  1. Run nix-shell new_shell.nix when in shells folder
  2. Change directory to test
  3. Running nix-shell results
    error: getting status of '/tmp/test/default.nix': No such file or directory
    Running nix-shell --packages results in evaluation of shellHook from new_shell.nix file and spawning new shell.
    Then repeating nix-shell ---packages runs shellHook again

Expected behavior

When running nix-shell --packages inside nix-shell configured by some file, shellHooks from previous shell are omitted for new shell.

nix-env --version output
nix-env (Nix) 2.18.1

Additional context

@abathur
Copy link
Member

abathur commented May 11, 2024

This is a duplicate of the following (though i guess the title doesn't make it obvious):

@fricklerhandwerk fricklerhandwerk closed this as not planned Won't fix, can't repro, duplicate, stale May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants