Skip to content

Latest commit

 

History

History
60 lines (45 loc) · 1.44 KB

File metadata and controls

60 lines (45 loc) · 1.44 KB

Lesson 05: A Reproducible Workbench

A development shell supplies project tools without making them permanent global packages. Everyone using the locked flake gets the same package definitions.

Add an output

In the output attribute set in flake.nix, keep the package output and add:

devShells.${system}.default = pkgs.mkShell {
  packages = with pkgs; [
    git
    nixfmt
    ripgrep
  ];
};

formatter.${system} = pkgs.nixfmt;

Attribute names such as devShells.x86_64-linux.default are an interface: nix develop looks there by convention.

Use the workbench

nix flake show
nix develop
rg --version
nixfmt --version
exit
nix fmt -- --check flake.nix

If the formatter reports a difference, run nix fmt flake.nix, inspect the diff, and learn what changed.

Checkpoint

git diff
git add flake.nix
git diff --staged
git commit -m "feat: add a reproducible Nix workbench"

Explain when a tool belongs in a development shell and when it should eventually belong in the laptop's system packages.

Completion checklist

  • nix develop opens my reproducible workbench.
  • I verified that the declared tools are available inside it.
  • nix fmt -- --check flake.nix passes.
  • I can explain the standard devShells and formatter output names.
  • I inspected and committed the change.
  • I ticked Lesson 05 in PROGRESS.md.

Next: Lesson 06.