Nix Shell

A non-flake version of documentation on Nix shell can be found here.

Links to this page
  • direnv: manage dev environments

    [!tip] Starship It is recommended to use starship along with nix-direnv, because it gives a visual indication of the current environment. For example, if you are in a Nix Shell, your terminal prompt automatically changes to something like this:

    direnv (along with nix-direnv) allows one to persist* nix development shell environments and share them seamlessly with text editors and IDEs. It obviates having to run nix develop manually every time you open a new terminal. The moment you cd into your project directory, the devshell is automatically activated, thanks to direnv.

  • VSCode
    Open VSCode from a terminal, inside of a devshell (i.e., nix develop -c code .), or
  • Rapid Introduction to Nix

    Like packages, another predefined flake output is devShells - which is used to provide a development shell aka. a nix shell or devshell. A devshell is a sandboxed environment containing the packages and other shell environment you specify. nixpkgs provides a function called mkShell that can be used to create devshells.

  • First steps with Nix

    One of the powers of Nix is that it enables us to create isolated shell environments containing just the packages we need. For eg., here’s how we create a transient shell containing the “cowsay” and “fortune” packages: