Skip to content

Getting started

Every example of this site is a runnable project, collected under examples in the source repository, and each one is also exposed as a flake template. The quickest way from an empty directory to a working Conan configuration is to instantiate one of them:

Terminal window
mkdir -p hello-conan && cd hello-conan
git init
nix flake init -t "git+https://codeberg.org/tarcisio/conan-flake"#templates.devenv-module-recipe

That template is the devenv example featuring a local-recipe-index remote; it carries a complete C++ project — a conanfile.py recipe, its sources and a test package — alongside the Conan configuration itself, which is the devenv.nix shown in the devenv chapter.

The shell can be activated with direnv:

Terminal window
direnv allow .

It can take a while before completing. After that, the conan command is available in the path, with the profile and the other Conan settings already in place, so the Conan package defined by the recipe can be built and tested with a call to conan create:

Terminal window
conan create . --build=missing

Whose output can be used to validate if the configuration was applied successfully:

hello-world: Hello World Release!
hello-world: __x86_64__ defined
hello-world: _GLIBCXX_USE_CXX11_ABI 1
hello-world: __cplusplus201703
hello-world: __GNUC__15
hello-world: __GNUC_MINOR__2
example/0.0.1 test_package

It’s also possible to interact directly with the example projects from a clone of this repository:1

Terminal window
git clone ssh://git@codeberg.org/tarcisio/conan-flake.git
cd conan-flake

The example above is on the examples/devenv-module-recipe directory:

Terminal window
cd examples/devenv-module-recipe
direnv allow .

And the same conan create call applies from there.

  • The option reference lists every option of the module, and carries the initial setup instructions for flake-parts scenarios.
  • The templates chapter lists the remaining templates, one per integration style.
  • The flake-parts, devenv and standalone chapters walk through each of those styles.
  1. Or, via https:

    Terminal window
    git clone https://codeberg.org/tarcisio/conan-flake.git
    cd conan-flake