The conan-flake module bridges the gap between Nix and the Conan C/C++ Package Manager, supporting a declarative configuration style and common development workflows. Conan profiles, remotes and tool requirements are declared as Nix options, and the Conan configuration files, the wrapper commands and the development shell are generated from them.
The module works with plain Nix (no flakes), Nix flakes,
flake-parts, or as a devenv
module.
A configuration declaring a Debug profile, the C++ standard to compile
against, and a cmake taken from Nix instead of built by Conan looks like this:
{profiles.default={settings.build_type="Debug";settings."compiler.cppstd"="14";platformToolRequires={cmake=pkgs.cmake.version;};};devShell={# Programs you want to make available in the shell:tools={inherit(pkgs)cmake;};};}From it, conan-flake renders the matching Conan profile — its [settings] and
[platform_tool_requires] sections — and puts cmake on the PATH of the
development shell, so that Conan resolves the tool from the environment instead
of building it. The entry page of
the documentation site shows the rendered profile next to these options.
Instantiate one of the templates into an empty directory:
nix flake init -t "git+https://codeberg.org/tarcisio/conan-flake"#templates.devenv-module-recipeThe getting started chapter takes that directory to a Conan package built with the generated configuration, and the other chapters cover the remaining ways of consuming the module.
The documentation site is at https://tarcisio.codeberg.page/conan-flake/:
- Getting started — from an empty directory to a working Conan configuration, and the example projects this repository ships.
- flake-parts —
the
flake-partsintegration: the flake inputs, theperSystem.conanoptions, and composing the generated development shell. - devenv — the devenv
integration, through devenv's own
languages.cplusplus.conanoption and with conan-flake used directly as a devenv module. - Standalone —
plain Nix usage, with and without flakes.
- evalConanConfig — evaluating a configuration directly.
- submoduleWith — embedding conan-flake in a larger option tree.
- Toolchains — configuring the compiler and the standard library conan-flake reports to Conan.
- Templates — every template of this flake and the command that instantiates it.
- Contributing — the development environment, the checks, and the generated blocks.
- References — the projects, tutorials and manuals this one builds on.
- Changelog — the revision history.
The option reference lists every
option of the module, generated from the module itself, along with initial setup
instructions for flake-parts scenarios.
Issues and pull requests are welcome at codeberg.org/tarcisio/conan-flake.
conan-flake is distributed under the terms of the MIT license — see LICENSE.