| src | ||
| subprojects | ||
| test | ||
| .clang-format | ||
| .clang-tidy | ||
| .dir-locals.el | ||
| .envrc | ||
| .gitignore | ||
| channels-lock.scm | ||
| channels.scm | ||
| LICENSE | ||
| Makefile | ||
| manifest.scm | ||
| meson.build | ||
| README.md | ||
C++ Project Template
This repository provides a minimal template for a C++ project, including source code, unit tests, and a reproducible development environment powered by Guix.
Project structure
src/contains all C++ source files;test/contains all unit tests;.clang-formatcontains the project-local clang-format settings;.clang-tidycontains the project-local clang-tidy settings;.envrcconfigures the host's direnv to use the Guix environment;manifest.scmdefines the development environment using Guix:channels.scmcontains the list of channels referred in the manifest;channels-lock.scmis the auto-generated list of channels versions referred in the environment;
meson.buildis the entry-point of the Meson's project configuration;.dir-locals.elcontains project-local definitions useful for Emacs;Makefilecontains the set of most frequent commands for this project.
Development environment
The development environment is defined declaratively in manifest.scm, which lists all required tools and libraries.
By relying on GNU Guix, the project guarantees:
- Reproducibility: everyone uses exactly the same compiler, tools, and library versions.
- Isolated development: the environment does not interfere with system packages.
- Easy onboarding: a single command sets everything up.
The most convenient method to access the development environment is to use direnv on the host machine.
With direnv installed and enabled in your shell, the project directory will automatically load the Guix environment described in manifest.scm upon entry, and unload it when leaving the directory. This avoids running guix shell ... manually each time.
Without direnv, to manually enter in the development environment:
guix time-machine -C channels-lock.scm -- shell -m manifest.scm
Whenever the dependencies change, you can update the development shell with:
make update-env
Makefile commands
For convenience, the Makefile includes all essential project commands:
make setup: configure the project environment;make build: compile the project;make test: build and run all unit tests;make clear: clean the project directory;make update-env: update the development environment dependencies (thechannels-lock.scmfile);