Installing a Python package in development mode in Nix Shell

I am trying to set up a development mode Nix Shell for a Python project I am working on. The project is, which according to the documentation is supported for a editable install. However, running nix-shell produces a classical installation of the package.

Here are the relevant shell.nix and default.nix I use:

# shell.nix

{ pkgs ? import <nixpkgs> {} }:

with pkgs;

mkShell {
  name = "roast-devshell";
  buildInputs = [ (callPackage ./. {}) ];
# default.nix

{ lib, pkgs ? import <nixpkgs> { } }:

with pkgs.python310Packages;

  f90nml = buildPythonPackage rec {
    pname = "f90nml";
    version = "1.3.1";
    src = fetchPypi {
      inherit pname version;
      sha256 =
buildPythonPackage rec {
  name = "roast";
  version = "0.1";
  src = ./.;
  propagatedBuildInputs = [ numpy matplotlib scipy pyfftw f90nml ];
  pythonImportsCheck = [ "roast" ];
  doCheck = false;

  meta = with lib; {
    description = "Post-processing tool dedicated to the CFD DNS solver POUSSINS";
    homepage = "";
    maintainers = with maintainers; [ loicreynier ];
    platforms = platforms.unix;

The documentation tells you to just create a default.nix containing the python package, not a shell.nix too where the package is a dependency. nix-shell works by creating and environment where the wanted package can be built by installing all the buildInputs and the tools to build the package. So remove the shell.nix and try again

1 Like

Thank you. I misunderstood the documentation. I removed the shell.nix and migrated to a flake.nix:

# flake.nix

  description = "ROAST";

  inputs.utils.url = "github:numtide/flake-utils";

  outputs = { self, utils, nixpkgs }:
      overlay = nixpkgs.lib.composeManyExtensions [
        (final: prev: { roast = final.callPackage ./. { }; })
    } // (utils.lib.eachDefaultSystem (system:
          pkgs = import nixpkgs {
            inherit system;
            overlays = [ self.overlay ];
          defaultPackage = pkgs.roast;

Now nix develop creates a proper “development mode” shell.

Following this, I was curious to know if it could be possible to have additional non-Python packages installed in the shell while keeping the package in development mode. My goal is to have a reproductive shell where I can have the package in development mode and all the external tools I use to work on it.

clearly it’s possible, there are various way to achieve it. For example you could use two “environments” one “inside” the other… a nix shell that installs the tools followed by your nix develop or you could use the same pip install -e inside shellHook of a devShell that installs your tools. There was another thread on installing python packages without nix just before this one, have a look at it. Just remember that the purpose of both nix-shell and nix develop is that of give you a shell environment where your package can be built, not that of dealing with the details of preparing an environment for this or that editing tool…

1 Like