An opinionated Nix-based template to ease the development of C++ programs
Nix 70.8%
Just 10.3%
Meson 8.6%
C++ 5.4%
C 2.1%
Shell 0.3%
Other 2.5%
4 1 0

Clone this repository

https://tangled.org/bpavuk.neocities.org/cxx-template https://tangled.org/did:plc:ab5inzxnpw4j2zvzlxupr5ut/cxx-template
git@knot.tangled.wizardry.systems:bpavuk.neocities.org/cxx-template git@knot.tangled.wizardry.systems:did:plc:ab5inzxnpw4j2zvzlxupr5ut/cxx-template

For self-hosted knots, clone URLs may differ based on your setup.

Download tar.gz
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.