Skip to content

For python, how to use venvShellHook with numtide / devshell #309

@geekodour

Description

@geekodour

We can use venvShellHook with plain shell.nix with something like

let
  pkgs = import <nixpkgs> { };
  pyPackages = pkgs.python311Packages;
in pkgs.mkShell {
  name = "py";
  venvDir = "./.venv";
  buildInputs = [
    pyPackages.pip
    pyPackages.venvShellHook
    pkgs.ruff # linter
    pkgs.python311
  ];

  postShellHook = ''
    pip install poetry
    unset SOURCE_DATE_EPOCH
  '';
}

And with vanilla flake with something like:

 devShells.default = pkgs.mkShell {
        nativeBuildInputs = with pkgs; [pkgs.python311Packages.pip pkgs.python311Packages.venvShellHook];
        venvDir = "./.venv";
 };

But with numtide / devshell it seems like I cannot use venvShellHook and hence no way to have the sweet virtual env created for me as I cd into the directory.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions