A practical walkthrough of using Nix as a C++ dependency manager, covering installation, writing custom Nix derivations for libraries like Catch2 and Google Benchmark, and switching between multiple compiler versions (Clang, GCC 6, GCC 7) with minimal effort. The post demonstrates how nix-shell environments provide reproducible, isolated builds, how the --pure flag enforces complete dependency declarations, and how nix-collect-garbage cleanly removes everything when done. Custom .nix expressions are shown for fetching header-only and compiled libraries from GitHub.
Table of contents
Use case exampleInstalling NixInstalling project dependenciesWriting our own Nix expressionsCompiling and running tests with different compilersFalloutPuritySummarySort: