YOUR JOURNEY
15 / 18
03THINKING IN FLAKES 7 MIN READ
LESSON 15 / A SHARED DEVELOPMENT SHELL

Your tools.
On every checkout.

Put a development environment next to the project that needs it.

A devShell declares tools and environment settings. nix develop enters that environment using the project’s locked inputs.

Explore the lesson
~$ Hands-on examples · Nix with flakes enabled.
THE NIX MODEL01 / 03
Drag to rotate

mkShell lists the tools needed for development.

flake.lockgitpython3mkShell
15.1A COMPLETE FIRST FLAKE

Start with a small toolchain.

Save this as flake.nix in a project directory. The example targets x86_64 Linux; use aarch64-linux for an ARM Linux machine. The output’s system key selects the platform, not an operating-system installation.

mkShell describes a development environment. It does not create a container or automatically pin Python packages from pip. Those dependencies need their own project strategy.

flake.nix
{
  description = "A shared development shell";
  inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
  outputs = { nixpkgs, ... }: let
    system = "x86_64-linux";
    pkgs = nixpkgs.legacyPackages.${system};
  in {
    devShells.${system}.default = pkgs.mkShell {
      packages = [ pkgs.git pkgs.python3 ];
      shellHook = ''
        echo "Development tools are ready."
      '';
    };
  };
}
Next section: One command at the project root.
15.2ENTER THE ENVIRONMENT

One command at the project root.

Add the file to Git, enter the shell, and check your tools. The first run may need downloads. Commit the generated lock file so your teammates use the same inputs.

exit leaves the shell. A shellHook runs when entering the development shell, so read a project’s Nix code before using it, just as you would inspect any setup script.

terminal
git add flake.nix
nix develop
python --version
git --version
exit
git add flake.lock
TAKE THIS WITH YOU

A devShell supplies project tools. Language-level dependencies still need to be declared and pinned.

Go a little deepernix develop reference
UP NEXT

Build & run outputs

A flake can expose something you can build and something you can run.

Next lesson