An opinionated Nix-based template to ease the development of C++ programs
Nix 73%
Just 10%
Meson 9%
C++ 6%
C 2%
Shell <1%

README.md

C++ Template #

Meson-based C++ starter with a Nix Flake dev shell that ships Clang, tooling, and a simple just workflow so you don't have to worry about Clangd hating the world.

Getting Started #

  1. Create a project from the template:
    nix flake init --template git@tangled.sh:bpavuk.neocities.org/cxx-template
    
  2. Enter the development shell (installs compilers, linters, debuggers):
    nix develop
    
  3. Configure and build:
    just sync   # runs meson setup --reconfigure build/
    just build  # runs meson compile -C build/
    ./build/cxx-template
    
    # or even simpler
    
    just        # runs both sync and build.
    ./build/cxx-template
    

You can also use direnv to get into the environment upon opening the directory:

direnv allow

To explore more just recipes, run just -l.

Project Layout #

  • meson.build, src/ - Meson project configuration and sources.
  • Justfile - Convenience tasks (sync, build, clean).
  • flake.nix - Dev-shell definition; tweak packages if you need extra tools.

Notes #

  • The template intentionally omits tests so you can plug in your preferred framework; add a Meson test() target when ready.
  • If you prefer GCC, remove the stdenv = pkgs.clangStdenv override inside flake.nix, and tune the CC and CXX variables.