An opinionated Nix-based template to ease the development of C++ programs
at main 43 lines 1.3 kB view raw view rendered
1# C++ Template 2 3Meson-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. 4 5## Getting Started 6 71. Create a project from the template: 8 ```sh 9 nix flake init --template git@tangled.sh:bpavuk.neocities.org/cxx-template 10 ``` 112. Enter the development shell (installs compilers, linters, debuggers): 12 ```sh 13 nix develop 14 ``` 153. Configure and build: 16 ```sh 17 just sync # runs meson setup --reconfigure build/ 18 just build # runs meson compile -C build/ 19 ./build/cxx-template 20 21 # or even simpler 22 23 just # runs both sync and build. 24 ./build/cxx-template 25 ``` 26 27You can also use `direnv` to get into the environment upon opening the directory: 28```sh 29direnv allow 30``` 31 32To explore more `just` recipes, run `just -l`. 33 34## Project Layout 35 36- `meson.build`, `src/` - Meson project configuration and sources. 37- `Justfile` - Convenience tasks (`sync`, `build`, `clean`). 38- `flake.nix` - Dev-shell definition; tweak packages if you need extra tools. 39 40## Notes 41 42- The template intentionally omits tests so you can plug in your preferred framework; add a Meson `test()` target when ready. 43- If you prefer GCC, remove the `stdenv = pkgs.clangStdenv` override inside `flake.nix`, and tune the `CC` and `CXX` variables.