Reproducible dev shells with Nix flakes
Pin the exact toolchain in the repository so every machine runs the same versions, without global installs.
“Works on my machine” is usually a version mismatch: a different Node, a different pnpm, a browser that is missing. A flake pins all of them next to the code.
{
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
outputs = { nixpkgs, ... }:
let pkgs = nixpkgs.legacyPackages.x86_64-linux;
in {
devShells.x86_64-linux.default = pkgs.mkShell {
packages = [ pkgs.nodejs pkgs.pnpm ];
};
};
}
nix develop drops you into a shell with exactly those tools. flake.lock records the nixpkgs commit, so the versions only change when you update the lock on purpose.
Keep it a development tool: CI and deploys can use their own setup and only need to match the major versions.