Nix 101 Course / Section 3: Dev shells: the productivity unlock
Premium

3.4 An extended dev shell without duplication

Lesson 21 of 68 · 7:21

placeholder thumbnail

Sign in, then buy this course to watch

Free account · no credit card needed

Video chapters

  1. 0:00 Shared Nix Definition for Dev and Release
  2. 1:24 Creating release.nix with tmux and devShell
  3. 3:09 Using the Dev Shell and Adding Extra Tools
  4. 4:54 Pointing nix build to release.nix
  5. 6:18 CI, Caching, and Looking Ahead to Flakes
Transcript

Shared Nix Definition for Dev and Release

0:00 So in the last video we dropped our shell.nix file and substituted by a default .nix file that does two things. We can now, from the same package definition, create a development shell and build a production build. And that is pretty cool, because the developers are now basically using the same toolchain, like the DevOps that will later use that application in production, put it into some Docker image or on the real-life system or whatever.

0:31 We basically have one definition for both use cases, the development incrementally and the fresh builds later. But you could now argue like, OK, look, it's nice that we just have one definition for both. But the context of a developer is that we typically need more tools than just that. So it's cool that the DevOps have a minimal sandbox now, but I need a language server and additional tools for that.

1:03 So what you can do now is say, OK, we could create a release.nix file and move all the code there. Let's close this. No, don't save.

The full transcript comes with the lesson.

About this lesson

Developers need more than the build does: language servers, linters, analyzers. But copying the package list into a second file means it goes stale. This lesson restructures the tmux project into a small release.nix layout where the package stays minimal and the dev shell inherits everything from it, then adds extra tools on top without repeating a single dependency.

In this video

  • Splitting the project into a package attribute and a devShell attribute in one release.nix
  • The mkShell feature that pulls a package's whole build environment into your shell, so the dependency list lives in exactly one place
  • Adding developer-only tools like shellcheck and Clang analyzers that never touch the production build
  • Wiring shell.nix and default.nix back up so nix-shell and nix-build both keep working
  • Why a CI that builds release.nix turns your shell definition into a tested artifact instead of a 300-step README

After this lesson

You can lay out a project where users run one command for the package, developers run one command for a richer shell, and neither definition can drift from the other.